n2words 3.1.0 → 5.0.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 (486) hide show
  1. package/CHANGELOG.md +51 -40
  2. package/LICENSE +1 -1
  3. package/README.md +64 -184
  4. package/dist/am-ET.js +2 -0
  5. package/dist/am-ET.umd.js +2 -0
  6. package/dist/am-Latn-ET.js +2 -0
  7. package/dist/am-Latn-ET.umd.js +2 -0
  8. package/dist/ar-SA.js +2 -0
  9. package/dist/ar-SA.umd.js +2 -0
  10. package/dist/az-AZ.js +2 -0
  11. package/dist/az-AZ.umd.js +2 -0
  12. package/dist/bn-BD.js +2 -0
  13. package/dist/bn-BD.umd.js +2 -0
  14. package/dist/cs-CZ.js +2 -0
  15. package/dist/cs-CZ.umd.js +2 -0
  16. package/dist/da-DK.js +2 -0
  17. package/dist/da-DK.umd.js +2 -0
  18. package/dist/de-DE.js +2 -0
  19. package/dist/de-DE.umd.js +2 -0
  20. package/dist/el-GR.js +2 -0
  21. package/dist/el-GR.umd.js +2 -0
  22. package/dist/en-AU.js +2 -0
  23. package/dist/en-AU.umd.js +2 -0
  24. package/dist/en-BD.js +2 -0
  25. package/dist/en-BD.umd.js +2 -0
  26. package/dist/en-CA.js +2 -0
  27. package/dist/en-CA.umd.js +2 -0
  28. package/dist/en-GB.js +2 -0
  29. package/dist/en-GB.umd.js +2 -0
  30. package/dist/en-GH.js +2 -0
  31. package/dist/en-GH.umd.js +2 -0
  32. package/dist/en-IE.js +2 -0
  33. package/dist/en-IE.umd.js +2 -0
  34. package/dist/en-IN.js +2 -0
  35. package/dist/en-IN.umd.js +2 -0
  36. package/dist/en-KE.js +2 -0
  37. package/dist/en-KE.umd.js +2 -0
  38. package/dist/en-MY.js +2 -0
  39. package/dist/en-MY.umd.js +2 -0
  40. package/dist/en-NG.js +2 -0
  41. package/dist/en-NG.umd.js +2 -0
  42. package/dist/en-NZ.js +2 -0
  43. package/dist/en-NZ.umd.js +2 -0
  44. package/dist/en-PH.js +2 -0
  45. package/dist/en-PH.umd.js +2 -0
  46. package/dist/en-PK.js +2 -0
  47. package/dist/en-PK.umd.js +2 -0
  48. package/dist/en-SG.js +2 -0
  49. package/dist/en-SG.umd.js +2 -0
  50. package/dist/en-US.js +2 -0
  51. package/dist/en-US.umd.js +2 -0
  52. package/dist/en-ZA.js +2 -0
  53. package/dist/en-ZA.umd.js +2 -0
  54. package/dist/es-ES.js +2 -0
  55. package/dist/es-ES.umd.js +2 -0
  56. package/dist/es-MX.js +2 -0
  57. package/dist/es-MX.umd.js +2 -0
  58. package/dist/es-US.js +2 -0
  59. package/dist/es-US.umd.js +2 -0
  60. package/dist/fa-IR.js +2 -0
  61. package/dist/fa-IR.umd.js +2 -0
  62. package/dist/fi-FI.js +2 -0
  63. package/dist/fi-FI.umd.js +2 -0
  64. package/dist/fil-PH.js +2 -0
  65. package/dist/fil-PH.umd.js +2 -0
  66. package/dist/fr-BE.js +2 -0
  67. package/dist/fr-BE.umd.js +2 -0
  68. package/dist/fr-FR.js +2 -0
  69. package/dist/fr-FR.umd.js +2 -0
  70. package/dist/gu-IN.js +2 -0
  71. package/dist/gu-IN.umd.js +2 -0
  72. package/dist/ha-NG.js +2 -0
  73. package/dist/ha-NG.umd.js +2 -0
  74. package/dist/hbo-IL.js +2 -0
  75. package/dist/hbo-IL.umd.js +2 -0
  76. package/dist/he-IL.js +2 -0
  77. package/dist/he-IL.umd.js +2 -0
  78. package/dist/hi-IN.js +2 -0
  79. package/dist/hi-IN.umd.js +2 -0
  80. package/dist/hr-HR.js +2 -0
  81. package/dist/hr-HR.umd.js +2 -0
  82. package/dist/hu-HU.js +2 -0
  83. package/dist/hu-HU.umd.js +2 -0
  84. package/dist/id-ID.js +2 -0
  85. package/dist/id-ID.umd.js +2 -0
  86. package/dist/it-IT.js +2 -0
  87. package/dist/it-IT.umd.js +2 -0
  88. package/dist/ja-JP.js +2 -0
  89. package/dist/ja-JP.umd.js +2 -0
  90. package/dist/ka-GE.js +2 -0
  91. package/dist/ka-GE.umd.js +2 -0
  92. package/dist/kn-IN.js +2 -0
  93. package/dist/kn-IN.umd.js +2 -0
  94. package/dist/ko-KR.js +2 -0
  95. package/dist/ko-KR.umd.js +2 -0
  96. package/dist/lt-LT.js +2 -0
  97. package/dist/lt-LT.umd.js +2 -0
  98. package/dist/lv-LV.js +2 -0
  99. package/dist/lv-LV.umd.js +2 -0
  100. package/dist/mr-IN.js +2 -0
  101. package/dist/mr-IN.umd.js +2 -0
  102. package/dist/ms-MY.js +2 -0
  103. package/dist/ms-MY.umd.js +2 -0
  104. package/dist/nb-NO.js +2 -0
  105. package/dist/nb-NO.umd.js +2 -0
  106. package/dist/nl-NL.js +2 -0
  107. package/dist/nl-NL.umd.js +2 -0
  108. package/dist/pa-IN.js +2 -0
  109. package/dist/pa-IN.umd.js +2 -0
  110. package/dist/pl-PL.js +2 -0
  111. package/dist/pl-PL.umd.js +2 -0
  112. package/dist/pt-BR.js +2 -0
  113. package/dist/pt-BR.umd.js +2 -0
  114. package/dist/pt-PT.js +2 -0
  115. package/dist/pt-PT.umd.js +2 -0
  116. package/dist/ro-RO.js +2 -0
  117. package/dist/ro-RO.umd.js +2 -0
  118. package/dist/ru-RU.js +2 -0
  119. package/dist/ru-RU.umd.js +2 -0
  120. package/dist/sr-Cyrl-RS.js +2 -0
  121. package/dist/sr-Cyrl-RS.umd.js +2 -0
  122. package/dist/sr-Latn-RS.js +2 -0
  123. package/dist/sr-Latn-RS.umd.js +2 -0
  124. package/dist/sv-SE.js +2 -0
  125. package/dist/sv-SE.umd.js +2 -0
  126. package/dist/sw-KE.js +2 -0
  127. package/dist/sw-KE.umd.js +2 -0
  128. package/dist/ta-IN.js +2 -0
  129. package/dist/ta-IN.umd.js +2 -0
  130. package/dist/te-IN.js +2 -0
  131. package/dist/te-IN.umd.js +2 -0
  132. package/dist/th-TH.js +2 -0
  133. package/dist/th-TH.umd.js +2 -0
  134. package/dist/tr-TR.js +2 -0
  135. package/dist/tr-TR.umd.js +2 -0
  136. package/dist/uk-UA.js +2 -0
  137. package/dist/uk-UA.umd.js +2 -0
  138. package/dist/ur-PK.js +2 -0
  139. package/dist/ur-PK.umd.js +2 -0
  140. package/dist/vi-VN.js +2 -0
  141. package/dist/vi-VN.umd.js +2 -0
  142. package/dist/yo-NG.js +2 -0
  143. package/dist/yo-NG.umd.js +2 -0
  144. package/dist/zh-Hans-CN.js +2 -0
  145. package/dist/zh-Hans-CN.umd.js +2 -0
  146. package/dist/zh-Hant-TW.js +2 -0
  147. package/dist/zh-Hant-TW.umd.js +2 -0
  148. package/package.json +61 -88
  149. package/src/am-ET.d.ts +40 -0
  150. package/src/am-ET.js +269 -0
  151. package/src/am-Latn-ET.d.ts +35 -0
  152. package/src/am-Latn-ET.js +264 -0
  153. package/src/ar-SA.d.ts +49 -0
  154. package/{lib/languages/ar.js → src/ar-SA.js} +177 -15
  155. package/src/az-AZ.d.ts +37 -0
  156. package/src/az-AZ.js +312 -0
  157. package/src/bn-BD.d.ts +36 -0
  158. package/{lib/languages/bn.js → src/bn-BD.js} +110 -6
  159. package/src/cs-CZ.d.ts +49 -0
  160. package/{lib/languages/cs.js → src/cs-CZ.js} +240 -14
  161. package/src/da-DK.d.ts +44 -0
  162. package/{lib/languages/da.js → src/da-DK.js} +131 -11
  163. package/src/de-DE.d.ts +57 -0
  164. package/src/de-DE.js +603 -0
  165. package/src/el-GR.d.ts +40 -0
  166. package/src/el-GR.js +418 -0
  167. package/src/en-AU.d.ts +47 -0
  168. package/src/en-AU.js +423 -0
  169. package/src/en-BD.d.ts +49 -0
  170. package/src/en-BD.js +415 -0
  171. package/src/en-CA.d.ts +63 -0
  172. package/src/en-CA.js +518 -0
  173. package/src/en-GB.d.ts +56 -0
  174. package/src/en-GB.js +469 -0
  175. package/src/en-GH.d.ts +11 -0
  176. package/src/en-GH.js +345 -0
  177. package/src/en-IE.d.ts +56 -0
  178. package/src/en-IE.js +479 -0
  179. package/src/en-IN.d.ts +49 -0
  180. package/src/en-IN.js +415 -0
  181. package/src/en-KE.d.ts +11 -0
  182. package/src/en-KE.js +345 -0
  183. package/src/en-MY.d.ts +11 -0
  184. package/src/en-MY.js +347 -0
  185. package/src/en-NG.d.ts +56 -0
  186. package/src/en-NG.js +479 -0
  187. package/src/en-NZ.d.ts +11 -0
  188. package/{lib/languages/en.js → src/en-NZ.js} +164 -31
  189. package/src/en-PH.d.ts +11 -0
  190. package/src/en-PH.js +345 -0
  191. package/src/en-PK.d.ts +49 -0
  192. package/src/en-PK.js +415 -0
  193. package/src/en-SG.d.ts +11 -0
  194. package/src/en-SG.js +345 -0
  195. package/src/en-US.d.ts +63 -0
  196. package/src/en-US.js +516 -0
  197. package/src/en-ZA.d.ts +56 -0
  198. package/src/en-ZA.js +478 -0
  199. package/src/es-ES.d.ts +65 -0
  200. package/src/es-ES.js +541 -0
  201. package/src/es-MX.d.ts +58 -0
  202. package/{lib/languages/es.js → src/es-MX.js} +228 -18
  203. package/src/es-US.d.ts +58 -0
  204. package/src/es-US.js +446 -0
  205. package/src/fa-IR.d.ts +38 -0
  206. package/src/fa-IR.js +246 -0
  207. package/src/fi-FI.d.ts +46 -0
  208. package/{lib/languages/fi.js → src/fi-FI.js} +152 -11
  209. package/src/fil-PH.d.ts +37 -0
  210. package/{lib/languages/fil.js → src/fil-PH.js} +144 -8
  211. package/src/fr-BE.d.ts +49 -0
  212. package/{lib/languages → src}/fr-BE.js +175 -13
  213. package/src/fr-FR.d.ts +63 -0
  214. package/{lib/languages/fr.js → src/fr-FR.js} +182 -16
  215. package/src/gu-IN.d.ts +35 -0
  216. package/{lib/languages/gu.js → src/gu-IN.js} +115 -6
  217. package/src/ha-NG.d.ts +37 -0
  218. package/{lib/languages/ha.js → src/ha-NG.js} +107 -8
  219. package/src/hbo-IL.d.ts +39 -0
  220. package/{lib/languages/hbo.js → src/hbo-IL.js} +211 -19
  221. package/src/he-IL.d.ts +37 -0
  222. package/src/he-IL.js +537 -0
  223. package/src/hi-IN.d.ts +36 -0
  224. package/{lib/languages/hi.js → src/hi-IN.js} +116 -6
  225. package/src/hr-HR.d.ts +42 -0
  226. package/src/hr-HR.js +463 -0
  227. package/src/hu-HU.d.ts +38 -0
  228. package/{lib/languages/hu.js → src/hu-HU.js} +164 -6
  229. package/src/id-ID.d.ts +38 -0
  230. package/{lib/languages/id.js → src/id-ID.js} +99 -8
  231. package/src/it-IT.d.ts +59 -0
  232. package/{lib/languages/it.js → src/it-IT.js} +179 -15
  233. package/src/ja-JP.d.ts +49 -0
  234. package/{lib/languages/ja.js → src/ja-JP.js} +111 -12
  235. package/src/ka-GE.d.ts +44 -0
  236. package/{lib/languages/ka.js → src/ka-GE.js} +113 -11
  237. package/src/kn-IN.d.ts +35 -0
  238. package/{lib/languages/kn.js → src/kn-IN.js} +115 -6
  239. package/src/ko-KR.d.ts +45 -0
  240. package/{lib/languages/ko.js → src/ko-KR.js} +94 -12
  241. package/src/lt-LT.d.ts +49 -0
  242. package/src/lt-LT.js +543 -0
  243. package/src/lv-LV.d.ts +49 -0
  244. package/src/lv-LV.js +595 -0
  245. package/src/mr-IN.d.ts +36 -0
  246. package/{lib/languages/mr.js → src/mr-IN.js} +116 -6
  247. package/src/ms-MY.d.ts +37 -0
  248. package/{lib/languages/ms.js → src/ms-MY.js} +111 -8
  249. package/src/nb-NO.d.ts +44 -0
  250. package/{lib/languages/nb.js → src/nb-NO.js} +153 -11
  251. package/src/nl-NL.d.ts +54 -0
  252. package/{lib/languages/nl.js → src/nl-NL.js} +260 -18
  253. package/src/pa-IN.d.ts +36 -0
  254. package/{lib/languages/pa.js → src/pa-IN.js} +116 -6
  255. package/src/pl-PL.d.ts +55 -0
  256. package/src/pl-PL.js +585 -0
  257. package/src/pt-BR.d.ts +31 -0
  258. package/src/pt-BR.js +534 -0
  259. package/src/pt-PT.d.ts +45 -0
  260. package/{lib/languages/pt.js → src/pt-PT.js} +234 -12
  261. package/src/ro-RO.d.ts +44 -0
  262. package/{lib/languages/ro.js → src/ro-RO.js} +212 -18
  263. package/src/ru-RU.d.ts +50 -0
  264. package/src/ru-RU.js +535 -0
  265. package/src/sr-Cyrl-RS.d.ts +49 -0
  266. package/src/sr-Cyrl-RS.js +503 -0
  267. package/src/sr-Latn-RS.d.ts +49 -0
  268. package/src/sr-Latn-RS.js +503 -0
  269. package/src/sv-SE.d.ts +44 -0
  270. package/{lib/languages/sv.js → src/sv-SE.js} +136 -11
  271. package/src/sw-KE.d.ts +37 -0
  272. package/{lib/languages/sw.js → src/sw-KE.js} +117 -6
  273. package/src/ta-IN.d.ts +35 -0
  274. package/{lib/languages/ta.js → src/ta-IN.js} +109 -6
  275. package/src/te-IN.d.ts +35 -0
  276. package/{lib/languages/te.js → src/te-IN.js} +115 -6
  277. package/src/th-TH.d.ts +38 -0
  278. package/{lib/languages/th.js → src/th-TH.js} +99 -6
  279. package/src/tr-TR.d.ts +48 -0
  280. package/{lib/languages/tr.js → src/tr-TR.js} +168 -23
  281. package/src/uk-UA.d.ts +42 -0
  282. package/src/uk-UA.js +463 -0
  283. package/src/ur-PK.d.ts +36 -0
  284. package/{lib/languages/ur.js → src/ur-PK.js} +116 -6
  285. package/src/utils/expand-scientific.d.ts +32 -0
  286. package/src/utils/expand-scientific.js +65 -0
  287. package/src/utils/parse-cardinal.d.ts +14 -0
  288. package/{lib/utils/parse-numeric.js → src/utils/parse-cardinal.js} +14 -44
  289. package/src/utils/parse-currency.d.ts +14 -0
  290. package/src/utils/parse-currency.js +91 -0
  291. package/src/utils/parse-ordinal.d.ts +10 -0
  292. package/src/utils/parse-ordinal.js +103 -0
  293. package/src/vi-VN.d.ts +48 -0
  294. package/{lib/languages/vi.js → src/vi-VN.js} +102 -11
  295. package/src/yo-NG.d.ts +37 -0
  296. package/{lib/languages/yo.js → src/yo-NG.js} +109 -9
  297. package/src/zh-Hans-CN.d.ts +48 -0
  298. package/{lib/languages/zh-Hans.js → src/zh-Hans-CN.js} +140 -8
  299. package/src/zh-Hant-TW.d.ts +50 -0
  300. package/{lib/languages/zh-Hant.js → src/zh-Hant-TW.js} +139 -8
  301. package/dist/languages/am-Latn.js +0 -3
  302. package/dist/languages/am-Latn.js.map +0 -1
  303. package/dist/languages/am.js +0 -3
  304. package/dist/languages/am.js.map +0 -1
  305. package/dist/languages/ar.js +0 -3
  306. package/dist/languages/ar.js.map +0 -1
  307. package/dist/languages/az.js +0 -3
  308. package/dist/languages/az.js.map +0 -1
  309. package/dist/languages/bn.js +0 -3
  310. package/dist/languages/bn.js.map +0 -1
  311. package/dist/languages/cs.js +0 -3
  312. package/dist/languages/cs.js.map +0 -1
  313. package/dist/languages/da.js +0 -3
  314. package/dist/languages/da.js.map +0 -1
  315. package/dist/languages/de.js +0 -3
  316. package/dist/languages/de.js.map +0 -1
  317. package/dist/languages/el.js +0 -3
  318. package/dist/languages/el.js.map +0 -1
  319. package/dist/languages/en.js +0 -3
  320. package/dist/languages/en.js.map +0 -1
  321. package/dist/languages/es.js +0 -3
  322. package/dist/languages/es.js.map +0 -1
  323. package/dist/languages/fa.js +0 -3
  324. package/dist/languages/fa.js.map +0 -1
  325. package/dist/languages/fi.js +0 -3
  326. package/dist/languages/fi.js.map +0 -1
  327. package/dist/languages/fil.js +0 -3
  328. package/dist/languages/fil.js.map +0 -1
  329. package/dist/languages/fr-BE.js +0 -3
  330. package/dist/languages/fr-BE.js.map +0 -1
  331. package/dist/languages/fr.js +0 -3
  332. package/dist/languages/fr.js.map +0 -1
  333. package/dist/languages/gu.js +0 -3
  334. package/dist/languages/gu.js.map +0 -1
  335. package/dist/languages/ha.js +0 -3
  336. package/dist/languages/ha.js.map +0 -1
  337. package/dist/languages/hbo.js +0 -3
  338. package/dist/languages/hbo.js.map +0 -1
  339. package/dist/languages/he.js +0 -3
  340. package/dist/languages/he.js.map +0 -1
  341. package/dist/languages/hi.js +0 -3
  342. package/dist/languages/hi.js.map +0 -1
  343. package/dist/languages/hr.js +0 -3
  344. package/dist/languages/hr.js.map +0 -1
  345. package/dist/languages/hu.js +0 -3
  346. package/dist/languages/hu.js.map +0 -1
  347. package/dist/languages/id.js +0 -3
  348. package/dist/languages/id.js.map +0 -1
  349. package/dist/languages/it.js +0 -3
  350. package/dist/languages/it.js.map +0 -1
  351. package/dist/languages/ja.js +0 -3
  352. package/dist/languages/ja.js.map +0 -1
  353. package/dist/languages/ka.js +0 -3
  354. package/dist/languages/ka.js.map +0 -1
  355. package/dist/languages/kn.js +0 -3
  356. package/dist/languages/kn.js.map +0 -1
  357. package/dist/languages/ko.js +0 -3
  358. package/dist/languages/ko.js.map +0 -1
  359. package/dist/languages/lt.js +0 -3
  360. package/dist/languages/lt.js.map +0 -1
  361. package/dist/languages/lv.js +0 -3
  362. package/dist/languages/lv.js.map +0 -1
  363. package/dist/languages/mr.js +0 -3
  364. package/dist/languages/mr.js.map +0 -1
  365. package/dist/languages/ms.js +0 -3
  366. package/dist/languages/ms.js.map +0 -1
  367. package/dist/languages/nb.js +0 -3
  368. package/dist/languages/nb.js.map +0 -1
  369. package/dist/languages/nl.js +0 -3
  370. package/dist/languages/nl.js.map +0 -1
  371. package/dist/languages/pa.js +0 -3
  372. package/dist/languages/pa.js.map +0 -1
  373. package/dist/languages/pl.js +0 -3
  374. package/dist/languages/pl.js.map +0 -1
  375. package/dist/languages/pt.js +0 -3
  376. package/dist/languages/pt.js.map +0 -1
  377. package/dist/languages/ro.js +0 -3
  378. package/dist/languages/ro.js.map +0 -1
  379. package/dist/languages/ru.js +0 -3
  380. package/dist/languages/ru.js.map +0 -1
  381. package/dist/languages/sr-Cyrl.js +0 -3
  382. package/dist/languages/sr-Cyrl.js.map +0 -1
  383. package/dist/languages/sr-Latn.js +0 -3
  384. package/dist/languages/sr-Latn.js.map +0 -1
  385. package/dist/languages/sv.js +0 -3
  386. package/dist/languages/sv.js.map +0 -1
  387. package/dist/languages/sw.js +0 -3
  388. package/dist/languages/sw.js.map +0 -1
  389. package/dist/languages/ta.js +0 -3
  390. package/dist/languages/ta.js.map +0 -1
  391. package/dist/languages/te.js +0 -3
  392. package/dist/languages/te.js.map +0 -1
  393. package/dist/languages/th.js +0 -3
  394. package/dist/languages/th.js.map +0 -1
  395. package/dist/languages/tr.js +0 -3
  396. package/dist/languages/tr.js.map +0 -1
  397. package/dist/languages/uk.js +0 -3
  398. package/dist/languages/uk.js.map +0 -1
  399. package/dist/languages/ur.js +0 -3
  400. package/dist/languages/ur.js.map +0 -1
  401. package/dist/languages/vi.js +0 -3
  402. package/dist/languages/vi.js.map +0 -1
  403. package/dist/languages/yo.js +0 -3
  404. package/dist/languages/yo.js.map +0 -1
  405. package/dist/languages/zh-Hans.js +0 -3
  406. package/dist/languages/zh-Hans.js.map +0 -1
  407. package/dist/languages/zh-Hant.js +0 -3
  408. package/dist/languages/zh-Hant.js.map +0 -1
  409. package/dist/n2words.js +0 -3
  410. package/dist/n2words.js.map +0 -1
  411. package/lib/languages/am-Latn.d.ts +0 -7
  412. package/lib/languages/am-Latn.js +0 -159
  413. package/lib/languages/am.d.ts +0 -7
  414. package/lib/languages/am.js +0 -159
  415. package/lib/languages/ar.d.ts +0 -17
  416. package/lib/languages/az.d.ts +0 -7
  417. package/lib/languages/az.js +0 -171
  418. package/lib/languages/bn.d.ts +0 -7
  419. package/lib/languages/cs.d.ts +0 -18
  420. package/lib/languages/da.d.ts +0 -14
  421. package/lib/languages/de.d.ts +0 -17
  422. package/lib/languages/de.js +0 -320
  423. package/lib/languages/el.d.ts +0 -14
  424. package/lib/languages/el.js +0 -236
  425. package/lib/languages/en.d.ts +0 -17
  426. package/lib/languages/es.d.ts +0 -21
  427. package/lib/languages/fa.d.ts +0 -7
  428. package/lib/languages/fa.js +0 -134
  429. package/lib/languages/fi.d.ts +0 -14
  430. package/lib/languages/fil.d.ts +0 -7
  431. package/lib/languages/fr-BE.d.ts +0 -11
  432. package/lib/languages/fr.d.ts +0 -21
  433. package/lib/languages/gu.d.ts +0 -7
  434. package/lib/languages/ha.d.ts +0 -7
  435. package/lib/languages/hbo.d.ts +0 -13
  436. package/lib/languages/he.d.ts +0 -13
  437. package/lib/languages/he.js +0 -265
  438. package/lib/languages/hi.d.ts +0 -7
  439. package/lib/languages/hr.d.ts +0 -11
  440. package/lib/languages/hr.js +0 -224
  441. package/lib/languages/hu.d.ts +0 -7
  442. package/lib/languages/id.d.ts +0 -7
  443. package/lib/languages/it.d.ts +0 -19
  444. package/lib/languages/ja.d.ts +0 -17
  445. package/lib/languages/ka.d.ts +0 -17
  446. package/lib/languages/kn.d.ts +0 -7
  447. package/lib/languages/ko.d.ts +0 -14
  448. package/lib/languages/lt.d.ts +0 -18
  449. package/lib/languages/lt.js +0 -301
  450. package/lib/languages/lv.d.ts +0 -18
  451. package/lib/languages/lv.js +0 -312
  452. package/lib/languages/mr.d.ts +0 -7
  453. package/lib/languages/ms.d.ts +0 -7
  454. package/lib/languages/nb.d.ts +0 -14
  455. package/lib/languages/nl.d.ts +0 -26
  456. package/lib/languages/pa.d.ts +0 -7
  457. package/lib/languages/pl.d.ts +0 -22
  458. package/lib/languages/pl.js +0 -317
  459. package/lib/languages/pt.d.ts +0 -17
  460. package/lib/languages/ro.d.ts +0 -18
  461. package/lib/languages/ru.d.ts +0 -11
  462. package/lib/languages/ru.js +0 -245
  463. package/lib/languages/sr-Cyrl.d.ts +0 -11
  464. package/lib/languages/sr-Cyrl.js +0 -221
  465. package/lib/languages/sr-Latn.d.ts +0 -11
  466. package/lib/languages/sr-Latn.js +0 -221
  467. package/lib/languages/sv.d.ts +0 -14
  468. package/lib/languages/sw.d.ts +0 -7
  469. package/lib/languages/ta.d.ts +0 -7
  470. package/lib/languages/te.d.ts +0 -7
  471. package/lib/languages/th.d.ts +0 -7
  472. package/lib/languages/tr.d.ts +0 -18
  473. package/lib/languages/uk.d.ts +0 -11
  474. package/lib/languages/uk.js +0 -224
  475. package/lib/languages/ur.d.ts +0 -7
  476. package/lib/languages/vi.d.ts +0 -17
  477. package/lib/languages/yo.d.ts +0 -7
  478. package/lib/languages/zh-Hans.d.ts +0 -11
  479. package/lib/languages/zh-Hant.d.ts +0 -11
  480. package/lib/n2words.d.ts +0 -55
  481. package/lib/n2words.js +0 -126
  482. package/lib/utils/parse-numeric.d.ts +0 -17
  483. /package/{lib → src}/utils/is-plain-object.d.ts +0 -0
  484. /package/{lib → src}/utils/is-plain-object.js +0 -0
  485. /package/{lib → src}/utils/validate-options.d.ts +0 -0
  486. /package/{lib → src}/utils/validate-options.js +0 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Scientific notation expansion utility.
3
+ * Converts scientific notation strings to full decimal form.
4
+ * @module expand-scientific
5
+ */
6
+ /**
7
+ * Expands scientific notation to full decimal form.
8
+ * Handles arbitrarily large exponents without precision loss.
9
+ *
10
+ * @param {string} str - String in scientific notation (e.g., "1e21", "1.5e-3")
11
+ * @returns {string} Full decimal representation (e.g., "1000000000000000000000", "0.0015")
12
+ *
13
+ * @example
14
+ * expandScientificNotation("1e21") // "1000000000000000000000"
15
+ * expandScientificNotation("1.5e3") // "1500"
16
+ * expandScientificNotation("1e-3") // "0.001"
17
+ */
18
+ export function expandScientificNotation(str: string): string;
19
+ /**
20
+ * Converts a number to decimal string, expanding scientific notation if needed.
21
+ *
22
+ * @param {number} value - The number to convert
23
+ * @returns {string} Decimal string representation
24
+ */
25
+ export function numberToString(value: number): string;
26
+ /**
27
+ * Checks if a string contains scientific notation.
28
+ *
29
+ * @param {string} str - String to check
30
+ * @returns {boolean} True if string contains 'e' or 'E'
31
+ */
32
+ export function hasScientificNotation(str: string): boolean;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Scientific notation expansion utility.
3
+ * Converts scientific notation strings to full decimal form.
4
+ * @module expand-scientific
5
+ */
6
+
7
+ /**
8
+ * Expands scientific notation to full decimal form.
9
+ * Handles arbitrarily large exponents without precision loss.
10
+ *
11
+ * @param {string} str - String in scientific notation (e.g., "1e21", "1.5e-3")
12
+ * @returns {string} Full decimal representation (e.g., "1000000000000000000000", "0.0015")
13
+ *
14
+ * @example
15
+ * expandScientificNotation("1e21") // "1000000000000000000000"
16
+ * expandScientificNotation("1.5e3") // "1500"
17
+ * expandScientificNotation("1e-3") // "0.001"
18
+ */
19
+ export function expandScientificNotation (str) {
20
+ let [mantissa, expStr] = str.toLowerCase().split('e')
21
+ const exp = parseInt(expStr, 10)
22
+
23
+ // Strip sign before processing digits
24
+ let sign = ''
25
+ if (mantissa[0] === '-') {
26
+ sign = '-'
27
+ mantissa = mantissa.slice(1)
28
+ }
29
+
30
+ const dotIndex = mantissa.indexOf('.')
31
+ const digits = dotIndex === -1
32
+ ? mantissa
33
+ : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)
34
+ const integerLength = dotIndex === -1 ? mantissa.length : dotIndex
35
+ const newDotPosition = integerLength + exp
36
+
37
+ if (newDotPosition >= digits.length) {
38
+ return sign + digits + '0'.repeat(newDotPosition - digits.length)
39
+ } else if (newDotPosition <= 0) {
40
+ return sign + '0.' + '0'.repeat(-newDotPosition) + digits
41
+ } else {
42
+ return sign + digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Converts a number to decimal string, expanding scientific notation if needed.
48
+ *
49
+ * @param {number} value - The number to convert
50
+ * @returns {string} Decimal string representation
51
+ */
52
+ export function numberToString (value) {
53
+ const str = value.toString()
54
+ return hasScientificNotation(str) ? expandScientificNotation(str) : str
55
+ }
56
+
57
+ /**
58
+ * Checks if a string contains scientific notation.
59
+ *
60
+ * @param {string} str - String to check
61
+ * @returns {boolean} True if string contains 'e' or 'E'
62
+ */
63
+ export function hasScientificNotation (str) {
64
+ return str.includes('e') || str.includes('E')
65
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Parses a value for cardinal conversion.
3
+ * Cardinals accept any numeric value: integers, decimals, negatives.
4
+ *
5
+ * @param {number|string|bigint} value - The value to parse
6
+ * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}
7
+ * @throws {TypeError} If value is not number, string, or bigint
8
+ * @throws {RangeError} If value is not finite
9
+ */
10
+ export function parseCardinalValue(value: number | string | bigint): {
11
+ isNegative: boolean;
12
+ integerPart: bigint;
13
+ decimalPart?: string;
14
+ };
@@ -1,17 +1,22 @@
1
1
  /**
2
- * Numeric value parsing utility.
2
+ * Cardinal value parsing utility.
3
3
  * Transforms user input (number, string, or bigint) into normalized components.
4
- * @module parse-numeric
4
+ * Handles negatives, decimals, and scientific notation.
5
+ * @module parse-cardinal
5
6
  */
6
7
 
8
+ import { expandScientificNotation, hasScientificNotation, numberToString } from './expand-scientific.js'
9
+
7
10
  /**
8
- * Parses a numeric value into its components.
9
- * @param {number|string|bigint} value
11
+ * Parses a value for cardinal conversion.
12
+ * Cardinals accept any numeric value: integers, decimals, negatives.
13
+ *
14
+ * @param {number|string|bigint} value - The value to parse
10
15
  * @returns {{isNegative: boolean, integerPart: bigint, decimalPart?: string}}
11
16
  * @throws {TypeError} If value is not number, string, or bigint
12
- * @throws {Error} If value is not a valid number format
17
+ * @throws {RangeError} If value is not finite
13
18
  */
14
- export function parseNumericValue (value) {
19
+ export function parseCardinalValue (value) {
15
20
  const type = typeof value
16
21
 
17
22
  // BigInt: simplest case
@@ -24,7 +29,7 @@ export function parseNumericValue (value) {
24
29
  // Number: fast path for safe integers
25
30
  if (type === 'number') {
26
31
  if (!Number.isFinite(value)) {
27
- throw new Error('Number must be finite (NaN and Infinity are not supported)')
32
+ throw new RangeError('Number must be finite (NaN and Infinity are not supported)')
28
33
  }
29
34
  if (Number.isSafeInteger(value)) {
30
35
  return value < 0
@@ -44,27 +49,15 @@ export function parseNumericValue (value) {
44
49
  )
45
50
  }
46
51
 
47
- /**
48
- * Converts a number to decimal string, expanding scientific notation if needed.
49
- */
50
- function numberToString (value) {
51
- const str = value.toString()
52
- return (str.includes('e') || str.includes('E'))
53
- ? expandScientificNotation(str)
54
- : str
55
- }
56
-
57
52
  /**
58
53
  * Validates and normalizes a string numeric input.
59
54
  */
60
55
  function normalizeString (value) {
61
56
  const trimmed = value.trim()
62
57
  if (trimmed.length === 0 || Number.isNaN(Number(trimmed))) {
63
- throw new Error(`Invalid number format: "${value}"`)
58
+ throw new RangeError(`Invalid number format: "${value}"`)
64
59
  }
65
- return (trimmed.includes('e') || trimmed.includes('E'))
66
- ? expandScientificNotation(trimmed)
67
- : trimmed
60
+ return hasScientificNotation(trimmed) ? expandScientificNotation(trimmed) : trimmed
68
61
  }
69
62
 
70
63
  /**
@@ -83,26 +76,3 @@ function parseNumericString (str) {
83
76
  const decimalPart = str.slice(dotIndex + 1)
84
77
  return { isNegative, integerPart: BigInt(integerStr), decimalPart }
85
78
  }
86
-
87
- /**
88
- * Expands scientific notation to decimal form (e.g., "1e21" → "1000...").
89
- */
90
- function expandScientificNotation (str) {
91
- const [mantissa, expStr] = str.toLowerCase().split('e')
92
- const exp = parseInt(expStr, 10)
93
-
94
- const dotIndex = mantissa.indexOf('.')
95
- const digits = dotIndex === -1
96
- ? mantissa
97
- : mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1)
98
- const integerLength = dotIndex === -1 ? mantissa.length : dotIndex
99
- const newDotPosition = integerLength + exp
100
-
101
- if (newDotPosition >= digits.length) {
102
- return digits + '0'.repeat(newDotPosition - digits.length)
103
- }
104
- if (newDotPosition <= 0) {
105
- return '0.' + '0'.repeat(-newDotPosition) + digits
106
- }
107
- return digits.slice(0, newDotPosition) + '.' + digits.slice(newDotPosition)
108
- }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Parses a value for currency conversion.
3
+ * Returns dollars and cents as separate bigints, plus negative flag.
4
+ *
5
+ * @param {number|string|bigint} value - The value to parse
6
+ * @returns {{isNegative: boolean, dollars: bigint, cents: bigint}}
7
+ * @throws {TypeError} If value is not number, string, or bigint
8
+ * @throws {RangeError} If value is not finite
9
+ */
10
+ export function parseCurrencyValue(value: number | string | bigint): {
11
+ isNegative: boolean;
12
+ dollars: bigint;
13
+ cents: bigint;
14
+ };
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Currency value parsing utility.
3
+ * Optimized parser for currency conversion - extracts dollars and cents.
4
+ * @module parse-currency
5
+ */
6
+
7
+ import { expandScientificNotation, hasScientificNotation, numberToString } from './expand-scientific.js'
8
+
9
+ /**
10
+ * Parses a value for currency conversion.
11
+ * Returns dollars and cents as separate bigints, plus negative flag.
12
+ *
13
+ * @param {number|string|bigint} value - The value to parse
14
+ * @returns {{isNegative: boolean, dollars: bigint, cents: bigint}}
15
+ * @throws {TypeError} If value is not number, string, or bigint
16
+ * @throws {RangeError} If value is not finite
17
+ */
18
+ export function parseCurrencyValue (value) {
19
+ const type = typeof value
20
+
21
+ // BigInt: whole dollars only
22
+ if (type === 'bigint') {
23
+ return value < 0n
24
+ ? { isNegative: true, dollars: -value, cents: 0n }
25
+ : { isNegative: false, dollars: value, cents: 0n }
26
+ }
27
+
28
+ // Number: fast path for safe integers
29
+ if (type === 'number') {
30
+ if (!Number.isFinite(value)) {
31
+ throw new RangeError('Currency must be a finite number')
32
+ }
33
+ if (Number.isSafeInteger(value)) {
34
+ return value < 0
35
+ ? { isNegative: true, dollars: BigInt(-value), cents: 0n }
36
+ : { isNegative: false, dollars: BigInt(value), cents: 0n }
37
+ }
38
+ // Non-integer or unsafe: convert to string
39
+ return parseCurrencyString(numberToString(value))
40
+ }
41
+
42
+ // String input
43
+ if (type === 'string') {
44
+ return parseCurrencyString(value)
45
+ }
46
+
47
+ throw new TypeError(
48
+ `Invalid value type: expected number, string, or bigint, received ${type}`
49
+ )
50
+ }
51
+
52
+ /**
53
+ * Parses a string for currency conversion.
54
+ *
55
+ * @param {string} value - The string to parse
56
+ * @returns {{isNegative: boolean, dollars: bigint, cents: bigint}}
57
+ */
58
+ function parseCurrencyString (value) {
59
+ let str = value.trim()
60
+
61
+ if (str.length === 0 || Number.isNaN(Number(str))) {
62
+ throw new RangeError(`Invalid currency format: "${value}"`)
63
+ }
64
+
65
+ // Expand scientific notation
66
+ if (hasScientificNotation(str)) {
67
+ str = expandScientificNotation(str)
68
+ }
69
+
70
+ // Handle negative
71
+ const isNegative = str[0] === '-'
72
+ if (isNegative) str = str.slice(1)
73
+
74
+ // Split on decimal
75
+ const dotIndex = str.indexOf('.')
76
+ if (dotIndex === -1) {
77
+ return { isNegative, dollars: BigInt(str), cents: 0n }
78
+ }
79
+
80
+ const dollarStr = str.slice(0, dotIndex) || '0'
81
+ const decimalPart = str.slice(dotIndex + 1)
82
+
83
+ // Truncate to 2 decimal places and pad if needed
84
+ const centStr = (decimalPart + '00').slice(0, 2)
85
+
86
+ return {
87
+ isNegative,
88
+ dollars: BigInt(dollarStr),
89
+ cents: BigInt(centStr)
90
+ }
91
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Parses a value for ordinal conversion.
3
+ * Ordinals require positive integers only (no zero, negatives, or decimals).
4
+ *
5
+ * @param {number|string|bigint} value - The value to parse
6
+ * @returns {bigint} The positive integer value
7
+ * @throws {TypeError} If value is not number, string, or bigint
8
+ * @throws {RangeError} If value is zero, negative, or has a decimal part
9
+ */
10
+ export function parseOrdinalValue(value: number | string | bigint): bigint;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Ordinal value parsing utility.
3
+ * Optimized parser for ordinal conversion - accepts only positive integers.
4
+ * @module parse-ordinal
5
+ */
6
+
7
+ import { expandScientificNotation, hasScientificNotation } from './expand-scientific.js'
8
+
9
+ /**
10
+ * Parses a value for ordinal conversion.
11
+ * Ordinals require positive integers only (no zero, negatives, or decimals).
12
+ *
13
+ * @param {number|string|bigint} value - The value to parse
14
+ * @returns {bigint} The positive integer value
15
+ * @throws {TypeError} If value is not number, string, or bigint
16
+ * @throws {RangeError} If value is zero, negative, or has a decimal part
17
+ */
18
+ export function parseOrdinalValue (value) {
19
+ const type = typeof value
20
+
21
+ // BigInt: simplest case
22
+ if (type === 'bigint') {
23
+ if (value <= 0n) {
24
+ throw new RangeError('Ordinals must be positive integers')
25
+ }
26
+ return value
27
+ }
28
+
29
+ // Number: fast path for safe integers
30
+ if (type === 'number') {
31
+ if (!Number.isFinite(value)) {
32
+ throw new RangeError('Ordinals must be finite numbers')
33
+ }
34
+ if (!Number.isInteger(value)) {
35
+ throw new RangeError('Ordinals must be whole numbers')
36
+ }
37
+ if (value <= 0) {
38
+ throw new RangeError('Ordinals must be positive integers')
39
+ }
40
+ return BigInt(value)
41
+ }
42
+
43
+ // String input
44
+ if (type === 'string') {
45
+ return parseOrdinalString(value)
46
+ }
47
+
48
+ throw new TypeError(
49
+ `Invalid value type: expected number, string, or bigint, received ${type}`
50
+ )
51
+ }
52
+
53
+ /**
54
+ * Parses a string for ordinal conversion.
55
+ *
56
+ * @param {string} value - The string to parse
57
+ * @returns {bigint} The positive integer value
58
+ * @throws {RangeError} If string is not a valid positive integer
59
+ */
60
+ function parseOrdinalString (value) {
61
+ const trimmed = value.trim()
62
+
63
+ if (trimmed.length === 0) {
64
+ throw new RangeError('Ordinals cannot be empty strings')
65
+ }
66
+
67
+ // Quick rejection for obvious non-ordinals
68
+ if (trimmed[0] === '-') {
69
+ throw new RangeError('Ordinals cannot be negative')
70
+ }
71
+
72
+ if (trimmed.includes('.')) {
73
+ throw new RangeError('Ordinals must be whole numbers')
74
+ }
75
+
76
+ // Handle scientific notation with full precision expansion
77
+ if (hasScientificNotation(trimmed)) {
78
+ const expanded = expandScientificNotation(trimmed)
79
+
80
+ // Check if expansion resulted in a decimal
81
+ if (expanded.includes('.')) {
82
+ throw new RangeError('Ordinals must be whole numbers')
83
+ }
84
+
85
+ const result = BigInt(expanded)
86
+ if (result <= 0n) {
87
+ throw new RangeError('Ordinals must be positive integers')
88
+ }
89
+ return result
90
+ }
91
+
92
+ // Parse as BigInt directly
93
+ try {
94
+ const result = BigInt(trimmed)
95
+ if (result <= 0n) {
96
+ throw new RangeError('Ordinals must be positive integers')
97
+ }
98
+ return result
99
+ } catch (e) {
100
+ if (e instanceof RangeError) throw e
101
+ throw new RangeError(`Invalid ordinal format: "${value}"`)
102
+ }
103
+ }
package/src/vi-VN.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Converts a numeric value to Vietnamese words.
3
+ *
4
+ * This is the main public API. It accepts any valid numeric input
5
+ * (number, string, or bigint) and handles parsing internally.
6
+ *
7
+ * @param {number | string | bigint} value - The numeric value to convert
8
+ * @returns {string} The number in Vietnamese words
9
+ * @throws {TypeError} If value is not a valid numeric type
10
+ * @throws {Error} If value is not a valid number format
11
+ *
12
+ * @example
13
+ * toCardinal(42) // 'bốn mươi hai'
14
+ * toCardinal(101) // 'một trăm lẻ một'
15
+ * toCardinal(1000000) // 'một triệu'
16
+ */
17
+ export function toCardinal(value: number | string | bigint): string;
18
+ /**
19
+ * Converts a numeric value to Vietnamese ordinal words.
20
+ *
21
+ * @param {number | string | bigint} value - The numeric value to convert (positive integer)
22
+ * @returns {string} The number as ordinal words
23
+ * @throws {TypeError} If value is not a valid numeric type
24
+ * @throws {RangeError} If value is negative, zero, or has a decimal part
25
+ *
26
+ * @example
27
+ * toOrdinal(1) // 'thứ nhất'
28
+ * toOrdinal(2) // 'thứ hai'
29
+ * toOrdinal(10) // 'thứ mười'
30
+ */
31
+ export function toOrdinal(value: number | string | bigint): string;
32
+ /**
33
+ * Converts a numeric value to Vietnamese currency words (Dong).
34
+ *
35
+ * Vietnamese Dong has no subunit in modern usage (xu are historical).
36
+ * Amounts are rounded to whole đồng.
37
+ *
38
+ * @param {number | string | bigint} value - The currency amount to convert
39
+ * @returns {string} The amount in Vietnamese currency words
40
+ * @throws {TypeError} If value is not a valid numeric type
41
+ * @throws {Error} If value is not a valid number format
42
+ *
43
+ * @example
44
+ * toCurrency(42) // 'bốn mươi hai đồng'
45
+ * toCurrency(1000) // 'một nghìn đồng'
46
+ * toCurrency(-5) // 'âm năm đồng'
47
+ */
48
+ export function toCurrency(value: number | string | bigint): string;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Vietnamese language converter - Functional Implementation
2
+ * Vietnamese (Vietnam) language converter
3
3
  *
4
- * Self-contained module with its own input validation, ready for subpath exports.
4
+ * CLDR: vi-VN | Vietnamese as used in Vietnam
5
5
  *
6
6
  * Vietnamese-specific rules:
7
7
  * - Special pronunciation: "lăm" for 5 in tens position, "mốt" for final 1
@@ -9,7 +9,9 @@
9
9
  * - Short scale system with Vietnamese words (nghìn, triệu, tỷ)
10
10
  */
11
11
 
12
- import { parseNumericValue } from '../utils/parse-numeric.js'
12
+ import { parseCardinalValue } from './utils/parse-cardinal.js'
13
+ import { parseCurrencyValue } from './utils/parse-currency.js'
14
+ import { parseOrdinalValue } from './utils/parse-ordinal.js'
13
15
 
14
16
  // ============================================================================
15
17
  // Vocabulary (module-level constants)
@@ -33,6 +35,20 @@ const NEGATIVE = 'âm'
33
35
  const DECIMAL_SEP = 'phẩy'
34
36
  const LE = 'lẻ' // "odd/extra" marker for gaps
35
37
 
38
+ // ============================================================================
39
+ // Ordinal Vocabulary
40
+ // ============================================================================
41
+
42
+ const ORDINAL_PREFIX = 'thứ'
43
+ // First is special: "thứ nhất" (not "thứ một")
44
+ const ORDINAL_ONE = 'nhất'
45
+
46
+ // ============================================================================
47
+ // Currency Vocabulary (Vietnamese Dong)
48
+ // ============================================================================
49
+
50
+ const DONG = 'đồng'
51
+
36
52
  // Special forms
37
53
  const MOT_FINAL = 'mốt' // 1 in tens position (21, 31, etc.)
38
54
  const LAM = 'lăm' // 5 in tens position (25, 35, etc.)
@@ -58,7 +74,7 @@ function buildBelowHundred (n) {
58
74
 
59
75
  // 20-99
60
76
  const ones = n % 10
61
- const tens = Math.floor(n / 10)
77
+ const tens = Math.trunc(n / 10)
62
78
  const tensWord = ONES[tens] + ' mươi'
63
79
 
64
80
  if (ones === 0) return tensWord
@@ -73,7 +89,7 @@ function buildBelowHundred (n) {
73
89
  function buildSegment (n) {
74
90
  if (n === 0) return ''
75
91
 
76
- const hundreds = Math.floor(n / 100)
92
+ const hundreds = Math.trunc(n / 100)
77
93
  const remainder = n % 100
78
94
 
79
95
  let result = ''
@@ -267,12 +283,12 @@ function decimalPartToWords (decimalPart) {
267
283
  * @throws {Error} If value is not a valid number format
268
284
  *
269
285
  * @example
270
- * toWords(42) // 'bốn mươi hai'
271
- * toWords(101) // 'một trăm lẻ một'
272
- * toWords(1000000) // 'một triệu'
286
+ * toCardinal(42) // 'bốn mươi hai'
287
+ * toCardinal(101) // 'một trăm lẻ một'
288
+ * toCardinal(1000000) // 'một triệu'
273
289
  */
274
- function toWords (value) {
275
- const { isNegative, integerPart, decimalPart } = parseNumericValue(value)
290
+ function toCardinal (value) {
291
+ const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
276
292
 
277
293
  let result = ''
278
294
 
@@ -289,8 +305,83 @@ function toWords (value) {
289
305
  return result
290
306
  }
291
307
 
308
+ // ============================================================================
309
+ // ORDINAL: toOrdinal(value)
310
+ // ============================================================================
311
+
312
+ /**
313
+ * Converts a non-negative integer to Vietnamese ordinal words.
314
+ *
315
+ * Vietnamese ordinals use "thứ" prefix + cardinal number.
316
+ * Special case: "thứ nhất" for 1st (not "thứ một").
317
+ *
318
+ * @param {bigint} n - Positive integer to convert
319
+ * @returns {string} Vietnamese ordinal words
320
+ */
321
+ function integerToOrdinal (n) {
322
+ // Special case: 1st is "thứ nhất"
323
+ if (n === 1n) {
324
+ return ORDINAL_PREFIX + ' ' + ORDINAL_ONE
325
+ }
326
+
327
+ // All others: "thứ" + cardinal
328
+ return ORDINAL_PREFIX + ' ' + integerToWords(n)
329
+ }
330
+
331
+ /**
332
+ * Converts a numeric value to Vietnamese ordinal words.
333
+ *
334
+ * @param {number | string | bigint} value - The numeric value to convert (positive integer)
335
+ * @returns {string} The number as ordinal words
336
+ * @throws {TypeError} If value is not a valid numeric type
337
+ * @throws {RangeError} If value is negative, zero, or has a decimal part
338
+ *
339
+ * @example
340
+ * toOrdinal(1) // 'thứ nhất'
341
+ * toOrdinal(2) // 'thứ hai'
342
+ * toOrdinal(10) // 'thứ mười'
343
+ */
344
+ function toOrdinal (value) {
345
+ const integerPart = parseOrdinalValue(value)
346
+ return integerToOrdinal(integerPart)
347
+ }
348
+
349
+ // ============================================================================
350
+ // CURRENCY: toCurrency(value)
351
+ // ============================================================================
352
+
353
+ /**
354
+ * Converts a numeric value to Vietnamese currency words (Dong).
355
+ *
356
+ * Vietnamese Dong has no subunit in modern usage (xu are historical).
357
+ * Amounts are rounded to whole đồng.
358
+ *
359
+ * @param {number | string | bigint} value - The currency amount to convert
360
+ * @returns {string} The amount in Vietnamese currency words
361
+ * @throws {TypeError} If value is not a valid numeric type
362
+ * @throws {Error} If value is not a valid number format
363
+ *
364
+ * @example
365
+ * toCurrency(42) // 'bốn mươi hai đồng'
366
+ * toCurrency(1000) // 'một nghìn đồng'
367
+ * toCurrency(-5) // 'âm năm đồng'
368
+ */
369
+ function toCurrency (value) {
370
+ const { isNegative, dollars: dong } = parseCurrencyValue(value)
371
+
372
+ let result = ''
373
+ if (isNegative) {
374
+ result = NEGATIVE + ' '
375
+ }
376
+
377
+ result += integerToWords(dong)
378
+ result += ' ' + DONG
379
+
380
+ return result
381
+ }
382
+
292
383
  // ============================================================================
293
384
  // Public API
294
385
  // ============================================================================
295
386
 
296
- export { toWords }
387
+ export { toCardinal, toOrdinal, toCurrency }
package/src/yo-NG.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Converts a numeric value to Yoruba words.
3
+ *
4
+ * @param {number | string | bigint} value - The numeric value to convert
5
+ * @returns {string} The number in Yoruba words
6
+ */
7
+ export function toCardinal(value: number | string | bigint): string;
8
+ /**
9
+ * Converts a numeric value to Yoruba ordinal words.
10
+ *
11
+ * @param {number | string | bigint} value - The numeric value to convert (positive integer)
12
+ * @returns {string} The number as ordinal words
13
+ * @throws {TypeError} If value is not a valid numeric type
14
+ * @throws {RangeError} If value is negative, zero, or has a decimal part
15
+ *
16
+ * @example
17
+ * toOrdinal(1) // 'àkọ́kọ́'
18
+ * toOrdinal(2) // 'ìkejì'
19
+ * toOrdinal(3) // 'ìkẹẹ̀ta'
20
+ */
21
+ export function toOrdinal(value: number | string | bigint): string;
22
+ /**
23
+ * Converts a numeric value to Yoruba currency words (Nigerian Naira).
24
+ *
25
+ * Uses náírà (naira) and kọ́bọ̀ (kobo).
26
+ *
27
+ * @param {number | string | bigint} value - The currency amount to convert
28
+ * @returns {string} The amount in Yoruba currency words
29
+ * @throws {TypeError} If value is not a valid numeric type
30
+ * @throws {Error} If value is not a valid number format
31
+ *
32
+ * @example
33
+ * toCurrency(42) // 'èjì lé lógójì náírà'
34
+ * toCurrency(1.50) // 'ọ̀kan náírà àti àádọ́ta kọ́bọ̀'
35
+ * toCurrency(-5) // 'àìní àrùn náírà'
36
+ */
37
+ export function toCurrency(value: number | string | bigint): string;