n2words 3.1.0 → 4.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 (482) hide show
  1. package/CHANGELOG.md +44 -0
  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-PT.js +2 -0
  113. package/dist/pt-PT.umd.js +2 -0
  114. package/dist/ro-RO.js +2 -0
  115. package/dist/ro-RO.umd.js +2 -0
  116. package/dist/ru-RU.js +2 -0
  117. package/dist/ru-RU.umd.js +2 -0
  118. package/dist/sr-Cyrl-RS.js +2 -0
  119. package/dist/sr-Cyrl-RS.umd.js +2 -0
  120. package/dist/sr-Latn-RS.js +2 -0
  121. package/dist/sr-Latn-RS.umd.js +2 -0
  122. package/dist/sv-SE.js +2 -0
  123. package/dist/sv-SE.umd.js +2 -0
  124. package/dist/sw-KE.js +2 -0
  125. package/dist/sw-KE.umd.js +2 -0
  126. package/dist/ta-IN.js +2 -0
  127. package/dist/ta-IN.umd.js +2 -0
  128. package/dist/te-IN.js +2 -0
  129. package/dist/te-IN.umd.js +2 -0
  130. package/dist/th-TH.js +2 -0
  131. package/dist/th-TH.umd.js +2 -0
  132. package/dist/tr-TR.js +2 -0
  133. package/dist/tr-TR.umd.js +2 -0
  134. package/dist/uk-UA.js +2 -0
  135. package/dist/uk-UA.umd.js +2 -0
  136. package/dist/ur-PK.js +2 -0
  137. package/dist/ur-PK.umd.js +2 -0
  138. package/dist/vi-VN.js +2 -0
  139. package/dist/vi-VN.umd.js +2 -0
  140. package/dist/yo-NG.js +2 -0
  141. package/dist/yo-NG.umd.js +2 -0
  142. package/dist/zh-Hans-CN.js +2 -0
  143. package/dist/zh-Hans-CN.umd.js +2 -0
  144. package/dist/zh-Hant-TW.js +2 -0
  145. package/dist/zh-Hant-TW.umd.js +2 -0
  146. package/package.json +47 -82
  147. package/src/am-ET.d.ts +40 -0
  148. package/src/am-ET.js +269 -0
  149. package/src/am-Latn-ET.d.ts +35 -0
  150. package/src/am-Latn-ET.js +264 -0
  151. package/src/ar-SA.d.ts +49 -0
  152. package/{lib/languages/ar.js → src/ar-SA.js} +177 -15
  153. package/src/az-AZ.d.ts +37 -0
  154. package/src/az-AZ.js +312 -0
  155. package/src/bn-BD.d.ts +36 -0
  156. package/{lib/languages/bn.js → src/bn-BD.js} +110 -6
  157. package/src/cs-CZ.d.ts +49 -0
  158. package/{lib/languages/cs.js → src/cs-CZ.js} +240 -14
  159. package/src/da-DK.d.ts +44 -0
  160. package/{lib/languages/da.js → src/da-DK.js} +131 -11
  161. package/src/de-DE.d.ts +57 -0
  162. package/src/de-DE.js +603 -0
  163. package/src/el-GR.d.ts +40 -0
  164. package/src/el-GR.js +418 -0
  165. package/src/en-AU.d.ts +47 -0
  166. package/src/en-AU.js +423 -0
  167. package/src/en-BD.d.ts +49 -0
  168. package/src/en-BD.js +415 -0
  169. package/src/en-CA.d.ts +63 -0
  170. package/src/en-CA.js +518 -0
  171. package/src/en-GB.d.ts +56 -0
  172. package/src/en-GB.js +469 -0
  173. package/src/en-GH.d.ts +11 -0
  174. package/src/en-GH.js +345 -0
  175. package/src/en-IE.d.ts +56 -0
  176. package/src/en-IE.js +479 -0
  177. package/src/en-IN.d.ts +49 -0
  178. package/src/en-IN.js +415 -0
  179. package/src/en-KE.d.ts +11 -0
  180. package/src/en-KE.js +345 -0
  181. package/src/en-MY.d.ts +11 -0
  182. package/src/en-MY.js +347 -0
  183. package/src/en-NG.d.ts +56 -0
  184. package/src/en-NG.js +479 -0
  185. package/src/en-NZ.d.ts +11 -0
  186. package/{lib/languages/en.js → src/en-NZ.js} +164 -31
  187. package/src/en-PH.d.ts +11 -0
  188. package/src/en-PH.js +345 -0
  189. package/src/en-PK.d.ts +49 -0
  190. package/src/en-PK.js +415 -0
  191. package/src/en-SG.d.ts +11 -0
  192. package/src/en-SG.js +345 -0
  193. package/src/en-US.d.ts +63 -0
  194. package/src/en-US.js +516 -0
  195. package/src/en-ZA.d.ts +56 -0
  196. package/src/en-ZA.js +478 -0
  197. package/src/es-ES.d.ts +65 -0
  198. package/src/es-ES.js +541 -0
  199. package/src/es-MX.d.ts +58 -0
  200. package/{lib/languages/es.js → src/es-MX.js} +228 -18
  201. package/src/es-US.d.ts +58 -0
  202. package/src/es-US.js +446 -0
  203. package/src/fa-IR.d.ts +38 -0
  204. package/src/fa-IR.js +246 -0
  205. package/src/fi-FI.d.ts +46 -0
  206. package/{lib/languages/fi.js → src/fi-FI.js} +152 -11
  207. package/src/fil-PH.d.ts +37 -0
  208. package/{lib/languages/fil.js → src/fil-PH.js} +144 -8
  209. package/src/fr-BE.d.ts +49 -0
  210. package/{lib/languages → src}/fr-BE.js +175 -13
  211. package/src/fr-FR.d.ts +63 -0
  212. package/{lib/languages/fr.js → src/fr-FR.js} +182 -16
  213. package/src/gu-IN.d.ts +35 -0
  214. package/{lib/languages/gu.js → src/gu-IN.js} +115 -6
  215. package/src/ha-NG.d.ts +37 -0
  216. package/{lib/languages/ha.js → src/ha-NG.js} +107 -8
  217. package/src/hbo-IL.d.ts +39 -0
  218. package/{lib/languages/hbo.js → src/hbo-IL.js} +211 -19
  219. package/src/he-IL.d.ts +37 -0
  220. package/src/he-IL.js +537 -0
  221. package/src/hi-IN.d.ts +36 -0
  222. package/{lib/languages/hi.js → src/hi-IN.js} +116 -6
  223. package/src/hr-HR.d.ts +42 -0
  224. package/src/hr-HR.js +463 -0
  225. package/src/hu-HU.d.ts +38 -0
  226. package/{lib/languages/hu.js → src/hu-HU.js} +164 -6
  227. package/src/id-ID.d.ts +38 -0
  228. package/{lib/languages/id.js → src/id-ID.js} +99 -8
  229. package/src/it-IT.d.ts +59 -0
  230. package/{lib/languages/it.js → src/it-IT.js} +179 -15
  231. package/src/ja-JP.d.ts +49 -0
  232. package/{lib/languages/ja.js → src/ja-JP.js} +111 -12
  233. package/src/ka-GE.d.ts +44 -0
  234. package/{lib/languages/ka.js → src/ka-GE.js} +113 -11
  235. package/src/kn-IN.d.ts +35 -0
  236. package/{lib/languages/kn.js → src/kn-IN.js} +115 -6
  237. package/src/ko-KR.d.ts +45 -0
  238. package/{lib/languages/ko.js → src/ko-KR.js} +94 -12
  239. package/src/lt-LT.d.ts +49 -0
  240. package/src/lt-LT.js +543 -0
  241. package/src/lv-LV.d.ts +49 -0
  242. package/src/lv-LV.js +595 -0
  243. package/src/mr-IN.d.ts +36 -0
  244. package/{lib/languages/mr.js → src/mr-IN.js} +116 -6
  245. package/src/ms-MY.d.ts +37 -0
  246. package/{lib/languages/ms.js → src/ms-MY.js} +111 -8
  247. package/src/nb-NO.d.ts +44 -0
  248. package/{lib/languages/nb.js → src/nb-NO.js} +153 -11
  249. package/src/nl-NL.d.ts +54 -0
  250. package/{lib/languages/nl.js → src/nl-NL.js} +260 -18
  251. package/src/pa-IN.d.ts +36 -0
  252. package/{lib/languages/pa.js → src/pa-IN.js} +116 -6
  253. package/src/pl-PL.d.ts +55 -0
  254. package/src/pl-PL.js +585 -0
  255. package/src/pt-PT.d.ts +45 -0
  256. package/{lib/languages/pt.js → src/pt-PT.js} +234 -12
  257. package/src/ro-RO.d.ts +44 -0
  258. package/{lib/languages/ro.js → src/ro-RO.js} +212 -18
  259. package/src/ru-RU.d.ts +50 -0
  260. package/src/ru-RU.js +535 -0
  261. package/src/sr-Cyrl-RS.d.ts +49 -0
  262. package/src/sr-Cyrl-RS.js +503 -0
  263. package/src/sr-Latn-RS.d.ts +49 -0
  264. package/src/sr-Latn-RS.js +503 -0
  265. package/src/sv-SE.d.ts +44 -0
  266. package/{lib/languages/sv.js → src/sv-SE.js} +136 -11
  267. package/src/sw-KE.d.ts +37 -0
  268. package/{lib/languages/sw.js → src/sw-KE.js} +117 -6
  269. package/src/ta-IN.d.ts +35 -0
  270. package/{lib/languages/ta.js → src/ta-IN.js} +109 -6
  271. package/src/te-IN.d.ts +35 -0
  272. package/{lib/languages/te.js → src/te-IN.js} +115 -6
  273. package/src/th-TH.d.ts +38 -0
  274. package/{lib/languages/th.js → src/th-TH.js} +99 -6
  275. package/src/tr-TR.d.ts +48 -0
  276. package/{lib/languages/tr.js → src/tr-TR.js} +168 -23
  277. package/src/uk-UA.d.ts +42 -0
  278. package/src/uk-UA.js +463 -0
  279. package/src/ur-PK.d.ts +36 -0
  280. package/{lib/languages/ur.js → src/ur-PK.js} +116 -6
  281. package/src/utils/expand-scientific.d.ts +32 -0
  282. package/src/utils/expand-scientific.js +65 -0
  283. package/src/utils/parse-cardinal.d.ts +14 -0
  284. package/{lib/utils/parse-numeric.js → src/utils/parse-cardinal.js} +14 -44
  285. package/src/utils/parse-currency.d.ts +14 -0
  286. package/src/utils/parse-currency.js +91 -0
  287. package/src/utils/parse-ordinal.d.ts +10 -0
  288. package/src/utils/parse-ordinal.js +103 -0
  289. package/src/vi-VN.d.ts +48 -0
  290. package/{lib/languages/vi.js → src/vi-VN.js} +102 -11
  291. package/src/yo-NG.d.ts +37 -0
  292. package/{lib/languages/yo.js → src/yo-NG.js} +109 -9
  293. package/src/zh-Hans-CN.d.ts +48 -0
  294. package/{lib/languages/zh-Hans.js → src/zh-Hans-CN.js} +140 -8
  295. package/src/zh-Hant-TW.d.ts +50 -0
  296. package/{lib/languages/zh-Hant.js → src/zh-Hant-TW.js} +139 -8
  297. package/dist/languages/am-Latn.js +0 -3
  298. package/dist/languages/am-Latn.js.map +0 -1
  299. package/dist/languages/am.js +0 -3
  300. package/dist/languages/am.js.map +0 -1
  301. package/dist/languages/ar.js +0 -3
  302. package/dist/languages/ar.js.map +0 -1
  303. package/dist/languages/az.js +0 -3
  304. package/dist/languages/az.js.map +0 -1
  305. package/dist/languages/bn.js +0 -3
  306. package/dist/languages/bn.js.map +0 -1
  307. package/dist/languages/cs.js +0 -3
  308. package/dist/languages/cs.js.map +0 -1
  309. package/dist/languages/da.js +0 -3
  310. package/dist/languages/da.js.map +0 -1
  311. package/dist/languages/de.js +0 -3
  312. package/dist/languages/de.js.map +0 -1
  313. package/dist/languages/el.js +0 -3
  314. package/dist/languages/el.js.map +0 -1
  315. package/dist/languages/en.js +0 -3
  316. package/dist/languages/en.js.map +0 -1
  317. package/dist/languages/es.js +0 -3
  318. package/dist/languages/es.js.map +0 -1
  319. package/dist/languages/fa.js +0 -3
  320. package/dist/languages/fa.js.map +0 -1
  321. package/dist/languages/fi.js +0 -3
  322. package/dist/languages/fi.js.map +0 -1
  323. package/dist/languages/fil.js +0 -3
  324. package/dist/languages/fil.js.map +0 -1
  325. package/dist/languages/fr-BE.js +0 -3
  326. package/dist/languages/fr-BE.js.map +0 -1
  327. package/dist/languages/fr.js +0 -3
  328. package/dist/languages/fr.js.map +0 -1
  329. package/dist/languages/gu.js +0 -3
  330. package/dist/languages/gu.js.map +0 -1
  331. package/dist/languages/ha.js +0 -3
  332. package/dist/languages/ha.js.map +0 -1
  333. package/dist/languages/hbo.js +0 -3
  334. package/dist/languages/hbo.js.map +0 -1
  335. package/dist/languages/he.js +0 -3
  336. package/dist/languages/he.js.map +0 -1
  337. package/dist/languages/hi.js +0 -3
  338. package/dist/languages/hi.js.map +0 -1
  339. package/dist/languages/hr.js +0 -3
  340. package/dist/languages/hr.js.map +0 -1
  341. package/dist/languages/hu.js +0 -3
  342. package/dist/languages/hu.js.map +0 -1
  343. package/dist/languages/id.js +0 -3
  344. package/dist/languages/id.js.map +0 -1
  345. package/dist/languages/it.js +0 -3
  346. package/dist/languages/it.js.map +0 -1
  347. package/dist/languages/ja.js +0 -3
  348. package/dist/languages/ja.js.map +0 -1
  349. package/dist/languages/ka.js +0 -3
  350. package/dist/languages/ka.js.map +0 -1
  351. package/dist/languages/kn.js +0 -3
  352. package/dist/languages/kn.js.map +0 -1
  353. package/dist/languages/ko.js +0 -3
  354. package/dist/languages/ko.js.map +0 -1
  355. package/dist/languages/lt.js +0 -3
  356. package/dist/languages/lt.js.map +0 -1
  357. package/dist/languages/lv.js +0 -3
  358. package/dist/languages/lv.js.map +0 -1
  359. package/dist/languages/mr.js +0 -3
  360. package/dist/languages/mr.js.map +0 -1
  361. package/dist/languages/ms.js +0 -3
  362. package/dist/languages/ms.js.map +0 -1
  363. package/dist/languages/nb.js +0 -3
  364. package/dist/languages/nb.js.map +0 -1
  365. package/dist/languages/nl.js +0 -3
  366. package/dist/languages/nl.js.map +0 -1
  367. package/dist/languages/pa.js +0 -3
  368. package/dist/languages/pa.js.map +0 -1
  369. package/dist/languages/pl.js +0 -3
  370. package/dist/languages/pl.js.map +0 -1
  371. package/dist/languages/pt.js +0 -3
  372. package/dist/languages/pt.js.map +0 -1
  373. package/dist/languages/ro.js +0 -3
  374. package/dist/languages/ro.js.map +0 -1
  375. package/dist/languages/ru.js +0 -3
  376. package/dist/languages/ru.js.map +0 -1
  377. package/dist/languages/sr-Cyrl.js +0 -3
  378. package/dist/languages/sr-Cyrl.js.map +0 -1
  379. package/dist/languages/sr-Latn.js +0 -3
  380. package/dist/languages/sr-Latn.js.map +0 -1
  381. package/dist/languages/sv.js +0 -3
  382. package/dist/languages/sv.js.map +0 -1
  383. package/dist/languages/sw.js +0 -3
  384. package/dist/languages/sw.js.map +0 -1
  385. package/dist/languages/ta.js +0 -3
  386. package/dist/languages/ta.js.map +0 -1
  387. package/dist/languages/te.js +0 -3
  388. package/dist/languages/te.js.map +0 -1
  389. package/dist/languages/th.js +0 -3
  390. package/dist/languages/th.js.map +0 -1
  391. package/dist/languages/tr.js +0 -3
  392. package/dist/languages/tr.js.map +0 -1
  393. package/dist/languages/uk.js +0 -3
  394. package/dist/languages/uk.js.map +0 -1
  395. package/dist/languages/ur.js +0 -3
  396. package/dist/languages/ur.js.map +0 -1
  397. package/dist/languages/vi.js +0 -3
  398. package/dist/languages/vi.js.map +0 -1
  399. package/dist/languages/yo.js +0 -3
  400. package/dist/languages/yo.js.map +0 -1
  401. package/dist/languages/zh-Hans.js +0 -3
  402. package/dist/languages/zh-Hans.js.map +0 -1
  403. package/dist/languages/zh-Hant.js +0 -3
  404. package/dist/languages/zh-Hant.js.map +0 -1
  405. package/dist/n2words.js +0 -3
  406. package/dist/n2words.js.map +0 -1
  407. package/lib/languages/am-Latn.d.ts +0 -7
  408. package/lib/languages/am-Latn.js +0 -159
  409. package/lib/languages/am.d.ts +0 -7
  410. package/lib/languages/am.js +0 -159
  411. package/lib/languages/ar.d.ts +0 -17
  412. package/lib/languages/az.d.ts +0 -7
  413. package/lib/languages/az.js +0 -171
  414. package/lib/languages/bn.d.ts +0 -7
  415. package/lib/languages/cs.d.ts +0 -18
  416. package/lib/languages/da.d.ts +0 -14
  417. package/lib/languages/de.d.ts +0 -17
  418. package/lib/languages/de.js +0 -320
  419. package/lib/languages/el.d.ts +0 -14
  420. package/lib/languages/el.js +0 -236
  421. package/lib/languages/en.d.ts +0 -17
  422. package/lib/languages/es.d.ts +0 -21
  423. package/lib/languages/fa.d.ts +0 -7
  424. package/lib/languages/fa.js +0 -134
  425. package/lib/languages/fi.d.ts +0 -14
  426. package/lib/languages/fil.d.ts +0 -7
  427. package/lib/languages/fr-BE.d.ts +0 -11
  428. package/lib/languages/fr.d.ts +0 -21
  429. package/lib/languages/gu.d.ts +0 -7
  430. package/lib/languages/ha.d.ts +0 -7
  431. package/lib/languages/hbo.d.ts +0 -13
  432. package/lib/languages/he.d.ts +0 -13
  433. package/lib/languages/he.js +0 -265
  434. package/lib/languages/hi.d.ts +0 -7
  435. package/lib/languages/hr.d.ts +0 -11
  436. package/lib/languages/hr.js +0 -224
  437. package/lib/languages/hu.d.ts +0 -7
  438. package/lib/languages/id.d.ts +0 -7
  439. package/lib/languages/it.d.ts +0 -19
  440. package/lib/languages/ja.d.ts +0 -17
  441. package/lib/languages/ka.d.ts +0 -17
  442. package/lib/languages/kn.d.ts +0 -7
  443. package/lib/languages/ko.d.ts +0 -14
  444. package/lib/languages/lt.d.ts +0 -18
  445. package/lib/languages/lt.js +0 -301
  446. package/lib/languages/lv.d.ts +0 -18
  447. package/lib/languages/lv.js +0 -312
  448. package/lib/languages/mr.d.ts +0 -7
  449. package/lib/languages/ms.d.ts +0 -7
  450. package/lib/languages/nb.d.ts +0 -14
  451. package/lib/languages/nl.d.ts +0 -26
  452. package/lib/languages/pa.d.ts +0 -7
  453. package/lib/languages/pl.d.ts +0 -22
  454. package/lib/languages/pl.js +0 -317
  455. package/lib/languages/pt.d.ts +0 -17
  456. package/lib/languages/ro.d.ts +0 -18
  457. package/lib/languages/ru.d.ts +0 -11
  458. package/lib/languages/ru.js +0 -245
  459. package/lib/languages/sr-Cyrl.d.ts +0 -11
  460. package/lib/languages/sr-Cyrl.js +0 -221
  461. package/lib/languages/sr-Latn.d.ts +0 -11
  462. package/lib/languages/sr-Latn.js +0 -221
  463. package/lib/languages/sv.d.ts +0 -14
  464. package/lib/languages/sw.d.ts +0 -7
  465. package/lib/languages/ta.d.ts +0 -7
  466. package/lib/languages/te.d.ts +0 -7
  467. package/lib/languages/th.d.ts +0 -7
  468. package/lib/languages/tr.d.ts +0 -18
  469. package/lib/languages/uk.d.ts +0 -11
  470. package/lib/languages/uk.js +0 -224
  471. package/lib/languages/ur.d.ts +0 -7
  472. package/lib/languages/vi.d.ts +0 -17
  473. package/lib/languages/yo.d.ts +0 -7
  474. package/lib/languages/zh-Hans.d.ts +0 -11
  475. package/lib/languages/zh-Hant.d.ts +0 -11
  476. package/lib/n2words.d.ts +0 -55
  477. package/lib/n2words.js +0 -126
  478. package/lib/utils/parse-numeric.d.ts +0 -17
  479. /package/{lib → src}/utils/is-plain-object.d.ts +0 -0
  480. /package/{lib → src}/utils/is-plain-object.js +0 -0
  481. /package/{lib → src}/utils/validate-options.d.ts +0 -0
  482. /package/{lib → src}/utils/validate-options.js +0 -0
@@ -1,17 +1,26 @@
1
1
  /**
2
- * English language converter - Functional Implementation
2
+ * New Zealand English language converter
3
3
  *
4
- * Self-contained module with its own input validation, ready for subpath exports.
4
+ * CLDR: en-NZ | English as used in New Zealand
5
5
  *
6
- * Key features:
7
- * - Western numbering system (thousand, million, billion)
6
+ * Exports:
7
+ * - toCardinal(value) - Cardinal numbers: 42 "forty-two"
8
+ * - toOrdinal(value) - Ordinal numbers: 42 → "forty-second"
9
+ * - toCurrency(value, options?) - Currency: 42.50 → "forty-two dollars and fifty cents"
10
+ *
11
+ * New Zealand English conventions:
12
+ * - Follows British English style
8
13
  * - "and" after hundreds: "one hundred and twenty-three"
14
+ * - "and" before final segment: "one million and one"
9
15
  * - Hyphenated tens-ones: "twenty-one", "forty-two"
10
- * - "and" before final segment when following scale word
11
- * - BigInt modulo for efficient segment extraction
16
+ * - Western numbering system (short scale: billion = 10^9)
17
+ * - Currency: New Zealand Dollar (NZD) - dollar/dollars, cent/cents
12
18
  */
13
19
 
14
- import { parseNumericValue } from '../utils/parse-numeric.js'
20
+ import { parseCardinalValue } from './utils/parse-cardinal.js'
21
+ import { parseCurrencyValue } from './utils/parse-currency.js'
22
+ import { parseOrdinalValue } from './utils/parse-ordinal.js'
23
+ import { validateOptions } from './utils/validate-options.js'
15
24
 
16
25
  // ============================================================================
17
26
  // Vocabulary (module-level constants)
@@ -21,13 +30,30 @@ const ONES = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'
21
30
  const TEENS = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
22
31
  const TENS = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
23
32
 
24
- const SCALES = ['thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion']
33
+ const SCALES = [
34
+ 'thousand', 'million', 'billion', 'trillion', 'quadrillion',
35
+ 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion',
36
+ 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quattuordecillion',
37
+ 'quindecillion', 'sexdecillion', 'septendecillion', 'octodecillion', 'novemdecillion',
38
+ 'vigintillion'
39
+ ]
25
40
 
26
41
  const HUNDRED = 'hundred'
27
42
  const ZERO = 'zero'
28
43
  const NEGATIVE = 'minus'
29
44
  const DECIMAL_SEP = 'point'
30
45
 
46
+ // Ordinal vocabulary
47
+ const ORDINAL_ONES = ['', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth']
48
+ const ORDINAL_TEENS = ['tenth', 'eleventh', 'twelfth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth']
49
+ const ORDINAL_TENS = ['', '', 'twentieth', 'thirtieth', 'fortieth', 'fiftieth', 'sixtieth', 'seventieth', 'eightieth', 'ninetieth']
50
+
51
+ // Currency vocabulary (New Zealand Dollar)
52
+ const DOLLAR = 'dollar'
53
+ const DOLLARS = 'dollars'
54
+ const CENT = 'cent'
55
+ const CENTS = 'cents'
56
+
31
57
  // ============================================================================
32
58
  // Segment Building
33
59
  // ============================================================================
@@ -118,14 +144,11 @@ function integerToWords (n) {
118
144
 
119
145
  /**
120
146
  * Builds words for numbers >= 1,000,000.
121
- * Uses BigInt division for faster segment extraction.
122
147
  *
123
148
  * @param {bigint} n - Number >= 1,000,000
124
149
  * @returns {string} English words
125
150
  */
126
151
  function buildLargeNumberWords (n) {
127
- // Extract segments using BigInt division
128
- // Segments are stored least-significant first (index 0 = ones, 1 = thousands, etc.)
129
152
  const segments = []
130
153
  let temp = n
131
154
  while (temp > 0n) {
@@ -133,7 +156,6 @@ function buildLargeNumberWords (n) {
133
156
  temp = temp / 1000n
134
157
  }
135
158
 
136
- // Find the first (smallest index) non-zero segment - this is processed last
137
159
  let firstNonZeroIdx = -1
138
160
  for (let i = 0; i < segments.length; i++) {
139
161
  if (segments[i] !== 0) {
@@ -142,7 +164,6 @@ function buildLargeNumberWords (n) {
142
164
  }
143
165
  }
144
166
 
145
- // Build result string (process from most-significant to least)
146
167
  let result = ''
147
168
  let prevWasScale = false
148
169
 
@@ -153,16 +174,13 @@ function buildLargeNumberWords (n) {
153
174
  const { word, hasHundred } = buildSegment(segment)
154
175
  const isLastSegment = (i === firstNonZeroIdx)
155
176
 
156
- // Add "and" only before FINAL segment if it follows scale and doesn't have hundred
157
177
  if (result && isLastSegment && prevWasScale && !hasHundred) {
158
178
  result += ' and'
159
179
  }
160
180
 
161
- // Add segment word
162
181
  if (result) result += ' '
163
182
  result += word
164
183
 
165
- // Add scale word (i=0 is units, i=1 is thousands, etc.)
166
184
  if (i > 0) {
167
185
  result += ' ' + SCALES[i - 1]
168
186
  prevWasScale = true
@@ -183,7 +201,6 @@ function buildLargeNumberWords (n) {
183
201
  function decimalPartToWords (decimalPart) {
184
202
  let result = ''
185
203
 
186
- // Handle leading zeros
187
204
  let i = 0
188
205
  while (i < decimalPart.length && decimalPart[i] === '0') {
189
206
  if (result) result += ' '
@@ -191,7 +208,6 @@ function decimalPartToWords (decimalPart) {
191
208
  i++
192
209
  }
193
210
 
194
- // Convert remainder as a single number
195
211
  const remainder = decimalPart.slice(i)
196
212
  if (remainder) {
197
213
  if (result) result += ' '
@@ -202,23 +218,15 @@ function decimalPartToWords (decimalPart) {
202
218
  }
203
219
 
204
220
  /**
205
- * Converts a numeric value to English words.
206
- *
207
- * This is the main public API. It accepts any valid numeric input
208
- * (number, string, or bigint) and handles parsing internally.
221
+ * Converts a numeric value to New Zealand English words.
209
222
  *
210
223
  * @param {number | string | bigint} value - The numeric value to convert
211
224
  * @returns {string} The number in English words
212
225
  * @throws {TypeError} If value is not a valid numeric type
213
226
  * @throws {Error} If value is not a valid number format
214
- *
215
- * @example
216
- * toWords(42) // 'forty-two'
217
- * toWords(-3.14) // 'minus three point one four'
218
- * toWords('1000000') // 'one million'
219
227
  */
220
- function toWords (value) {
221
- const { isNegative, integerPart, decimalPart } = parseNumericValue(value)
228
+ function toCardinal (value) {
229
+ const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
222
230
 
223
231
  let result = ''
224
232
 
@@ -236,7 +244,132 @@ function toWords (value) {
236
244
  }
237
245
 
238
246
  // ============================================================================
239
- // Public API
247
+ // ORDINAL
248
+ // ============================================================================
249
+
250
+ function buildOrdinalSegment (n) {
251
+ const ones = n % 10
252
+ const tens = Math.trunc(n / 10) % 10
253
+ const hundreds = Math.trunc(n / 100)
254
+
255
+ let tensOnesOrdinal = ''
256
+ if (tens === 1) {
257
+ tensOnesOrdinal = ORDINAL_TEENS[ones]
258
+ } else if (tens >= 2) {
259
+ if (ones > 0) {
260
+ tensOnesOrdinal = TENS[tens] + '-' + ORDINAL_ONES[ones]
261
+ } else {
262
+ tensOnesOrdinal = ORDINAL_TENS[tens]
263
+ }
264
+ } else if (ones > 0) {
265
+ tensOnesOrdinal = ORDINAL_ONES[ones]
266
+ }
267
+
268
+ if (hundreds > 0) {
269
+ if (tensOnesOrdinal) {
270
+ return ONES[hundreds] + ' ' + HUNDRED + ' ' + tensOnesOrdinal
271
+ } else {
272
+ return ONES[hundreds] + ' hundredth'
273
+ }
274
+ }
275
+
276
+ return tensOnesOrdinal
277
+ }
278
+
279
+ function integerToOrdinal (n) {
280
+ if (n < 1000n) {
281
+ return buildOrdinalSegment(Number(n))
282
+ }
283
+
284
+ if (n < 1_000_000n) {
285
+ const thousands = Number(n / 1000n)
286
+ const remainder = Number(n % 1000n)
287
+
288
+ if (remainder === 0) {
289
+ return buildSegment(thousands).word + ' ' + SCALES[0] + 'th'
290
+ }
291
+
292
+ const { word: thousandsWord } = buildSegment(thousands)
293
+ return thousandsWord + ' ' + SCALES[0] + ' ' + buildOrdinalSegment(remainder)
294
+ }
295
+
296
+ return buildLargeOrdinal(n)
297
+ }
298
+
299
+ function buildLargeOrdinal (n) {
300
+ const segments = []
301
+ let temp = n
302
+ while (temp > 0n) {
303
+ segments.push(Number(temp % 1000n))
304
+ temp = temp / 1000n
305
+ }
306
+
307
+ let lowestNonZeroIdx = 0
308
+ for (let i = 0; i < segments.length; i++) {
309
+ if (segments[i] !== 0) {
310
+ lowestNonZeroIdx = i
311
+ break
312
+ }
313
+ }
314
+
315
+ let result = ''
316
+
317
+ for (let i = segments.length - 1; i >= 0; i--) {
318
+ const segment = segments[i]
319
+ if (segment === 0) continue
320
+
321
+ const isLowestSegment = (i === lowestNonZeroIdx)
322
+
323
+ if (result) result += ' '
324
+
325
+ if (isLowestSegment) {
326
+ if (i === 0) {
327
+ result += buildOrdinalSegment(segment)
328
+ } else {
329
+ result += buildSegment(segment).word + ' ' + SCALES[i - 1] + 'th'
330
+ }
331
+ } else {
332
+ result += buildSegment(segment).word
333
+ if (i > 0) {
334
+ result += ' ' + SCALES[i - 1]
335
+ }
336
+ }
337
+ }
338
+
339
+ return result
340
+ }
341
+
342
+ function toOrdinal (value) {
343
+ const integerPart = parseOrdinalValue(value)
344
+ return integerToOrdinal(integerPart)
345
+ }
346
+
347
+ // ============================================================================
348
+ // CURRENCY
240
349
  // ============================================================================
241
350
 
242
- export { toWords }
351
+ function toCurrency (value, options) {
352
+ options = validateOptions(options)
353
+ const { isNegative, dollars, cents } = parseCurrencyValue(value)
354
+ const { and: useAnd = true } = options
355
+
356
+ let result = ''
357
+ if (isNegative) result = NEGATIVE + ' '
358
+
359
+ if (dollars > 0n || cents === 0n) {
360
+ result += integerToWords(dollars)
361
+ result += ' ' + (dollars === 1n ? DOLLAR : DOLLARS)
362
+ }
363
+
364
+ if (cents > 0n) {
365
+ if (dollars > 0n) {
366
+ result += useAnd ? ' and ' : ' '
367
+ }
368
+ result += integerToWords(cents)
369
+ result += ' ' + (cents === 1n ? CENT : CENTS)
370
+ }
371
+
372
+ return result
373
+ }
374
+
375
+ export { toCardinal, toOrdinal, toCurrency }
package/src/en-PH.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Converts a numeric value to Philippine English words.
3
+ *
4
+ * @param {number | string | bigint} value - The numeric value to convert
5
+ * @returns {string} The number in English words
6
+ * @throws {TypeError} If value is not a valid numeric type
7
+ * @throws {Error} If value is not a valid number format
8
+ */
9
+ export function toCardinal(value: number | string | bigint): string;
10
+ export function toOrdinal(value: any): string;
11
+ export function toCurrency(value: any, options: any): string;
package/src/en-PH.js ADDED
@@ -0,0 +1,345 @@
1
+ /**
2
+ * Philippine English language converter
3
+ *
4
+ * CLDR: en-PH | English as used in the Philippines
5
+ *
6
+ * Exports:
7
+ * - toCardinal(value) - Cardinal numbers: 42 → "forty-two"
8
+ * - toOrdinal(value) - Ordinal numbers: 42 → "forty-second"
9
+ * - toCurrency(value, options?) - Currency: 42.50 → "forty-two pesos and fifty centavos"
10
+ *
11
+ * Philippine English conventions:
12
+ * - Follows British English style
13
+ * - "and" after hundreds: "one hundred and twenty-three"
14
+ * - "and" before final segment: "one million and one"
15
+ * - Hyphenated tens-ones: "twenty-one", "forty-two"
16
+ * - Western numbering system (short scale: billion = 10^9)
17
+ * - Currency: Philippine Peso (PHP) - peso/pesos, centavo/centavos
18
+ */
19
+
20
+ import { parseCardinalValue } from './utils/parse-cardinal.js'
21
+ import { parseCurrencyValue } from './utils/parse-currency.js'
22
+ import { parseOrdinalValue } from './utils/parse-ordinal.js'
23
+ import { validateOptions } from './utils/validate-options.js'
24
+
25
+ // ============================================================================
26
+ // Vocabulary (module-level constants)
27
+ // ============================================================================
28
+
29
+ const ONES = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
30
+ const TEENS = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
31
+ const TENS = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
32
+
33
+ const SCALES = [
34
+ 'thousand', 'million', 'billion', 'trillion', 'quadrillion',
35
+ 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion',
36
+ 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quattuordecillion',
37
+ 'quindecillion', 'sexdecillion', 'septendecillion', 'octodecillion', 'novemdecillion',
38
+ 'vigintillion'
39
+ ]
40
+
41
+ const HUNDRED = 'hundred'
42
+ const ZERO = 'zero'
43
+ const NEGATIVE = 'minus'
44
+ const DECIMAL_SEP = 'point'
45
+
46
+ // Ordinal vocabulary
47
+ const ORDINAL_ONES = ['', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth']
48
+ const ORDINAL_TEENS = ['tenth', 'eleventh', 'twelfth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth']
49
+ const ORDINAL_TENS = ['', '', 'twentieth', 'thirtieth', 'fortieth', 'fiftieth', 'sixtieth', 'seventieth', 'eightieth', 'ninetieth']
50
+
51
+ // Currency vocabulary (Philippine Peso)
52
+ const PESO = 'peso'
53
+ const PESOS = 'pesos'
54
+ const CENTAVO = 'centavo'
55
+ const CENTAVOS = 'centavos'
56
+
57
+ // ============================================================================
58
+ // Segment Building
59
+ // ============================================================================
60
+
61
+ const segmentResult = { word: '', hasHundred: false }
62
+
63
+ function buildSegment (n) {
64
+ if (n === 0) {
65
+ segmentResult.word = ''
66
+ segmentResult.hasHundred = false
67
+ return segmentResult
68
+ }
69
+
70
+ const ones = n % 10
71
+ const tens = Math.trunc(n / 10) % 10
72
+ const hundreds = Math.trunc(n / 100)
73
+
74
+ let tensOnes = ''
75
+ if (tens === 1) {
76
+ tensOnes = TEENS[ones]
77
+ } else if (tens >= 2) {
78
+ tensOnes = ones > 0 ? TENS[tens] + '-' + ONES[ones] : TENS[tens]
79
+ } else if (ones > 0) {
80
+ tensOnes = ONES[ones]
81
+ }
82
+
83
+ if (hundreds > 0) {
84
+ if (tensOnes) {
85
+ segmentResult.word = ONES[hundreds] + ' ' + HUNDRED + ' and ' + tensOnes
86
+ } else {
87
+ segmentResult.word = ONES[hundreds] + ' ' + HUNDRED
88
+ }
89
+ segmentResult.hasHundred = true
90
+ } else {
91
+ segmentResult.word = tensOnes
92
+ segmentResult.hasHundred = false
93
+ }
94
+
95
+ return segmentResult
96
+ }
97
+
98
+ // ============================================================================
99
+ // Conversion Functions
100
+ // ============================================================================
101
+
102
+ function integerToWords (n) {
103
+ if (n === 0n) return ZERO
104
+
105
+ if (n < 1000n) {
106
+ return buildSegment(Number(n)).word
107
+ }
108
+
109
+ if (n < 1_000_000n) {
110
+ const thousands = Number(n / 1000n)
111
+ const remainder = Number(n % 1000n)
112
+
113
+ const { word: thousandsWord } = buildSegment(thousands)
114
+ let result = thousandsWord + ' ' + SCALES[0]
115
+
116
+ if (remainder > 0) {
117
+ const { word: remainderWord, hasHundred } = buildSegment(remainder)
118
+ result += hasHundred ? ' ' + remainderWord : ' and ' + remainderWord
119
+ }
120
+
121
+ return result
122
+ }
123
+
124
+ return buildLargeNumberWords(n)
125
+ }
126
+
127
+ function buildLargeNumberWords (n) {
128
+ const segments = []
129
+ let temp = n
130
+ while (temp > 0n) {
131
+ segments.push(Number(temp % 1000n))
132
+ temp = temp / 1000n
133
+ }
134
+
135
+ let firstNonZeroIdx = -1
136
+ for (let i = 0; i < segments.length; i++) {
137
+ if (segments[i] !== 0) {
138
+ firstNonZeroIdx = i
139
+ break
140
+ }
141
+ }
142
+
143
+ let result = ''
144
+ let prevWasScale = false
145
+
146
+ for (let i = segments.length - 1; i >= 0; i--) {
147
+ const segment = segments[i]
148
+ if (segment === 0) continue
149
+
150
+ const { word, hasHundred } = buildSegment(segment)
151
+ const isLastSegment = (i === firstNonZeroIdx)
152
+
153
+ if (result && isLastSegment && prevWasScale && !hasHundred) {
154
+ result += ' and'
155
+ }
156
+
157
+ if (result) result += ' '
158
+ result += word
159
+
160
+ if (i > 0) {
161
+ result += ' ' + SCALES[i - 1]
162
+ prevWasScale = true
163
+ } else {
164
+ prevWasScale = false
165
+ }
166
+ }
167
+
168
+ return result
169
+ }
170
+
171
+ function decimalPartToWords (decimalPart) {
172
+ let result = ''
173
+
174
+ let i = 0
175
+ while (i < decimalPart.length && decimalPart[i] === '0') {
176
+ if (result) result += ' '
177
+ result += ZERO
178
+ i++
179
+ }
180
+
181
+ const remainder = decimalPart.slice(i)
182
+ if (remainder) {
183
+ if (result) result += ' '
184
+ result += integerToWords(BigInt(remainder))
185
+ }
186
+
187
+ return result
188
+ }
189
+
190
+ /**
191
+ * Converts a numeric value to Philippine English words.
192
+ *
193
+ * @param {number | string | bigint} value - The numeric value to convert
194
+ * @returns {string} The number in English words
195
+ * @throws {TypeError} If value is not a valid numeric type
196
+ * @throws {Error} If value is not a valid number format
197
+ */
198
+ function toCardinal (value) {
199
+ const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
200
+
201
+ let result = ''
202
+
203
+ if (isNegative) {
204
+ result = NEGATIVE + ' '
205
+ }
206
+
207
+ result += integerToWords(integerPart)
208
+
209
+ if (decimalPart) {
210
+ result += ' ' + DECIMAL_SEP + ' ' + decimalPartToWords(decimalPart)
211
+ }
212
+
213
+ return result
214
+ }
215
+
216
+ // ============================================================================
217
+ // ORDINAL
218
+ // ============================================================================
219
+
220
+ function buildOrdinalSegment (n) {
221
+ const ones = n % 10
222
+ const tens = Math.trunc(n / 10) % 10
223
+ const hundreds = Math.trunc(n / 100)
224
+
225
+ let tensOnesOrdinal = ''
226
+ if (tens === 1) {
227
+ tensOnesOrdinal = ORDINAL_TEENS[ones]
228
+ } else if (tens >= 2) {
229
+ if (ones > 0) {
230
+ tensOnesOrdinal = TENS[tens] + '-' + ORDINAL_ONES[ones]
231
+ } else {
232
+ tensOnesOrdinal = ORDINAL_TENS[tens]
233
+ }
234
+ } else if (ones > 0) {
235
+ tensOnesOrdinal = ORDINAL_ONES[ones]
236
+ }
237
+
238
+ if (hundreds > 0) {
239
+ if (tensOnesOrdinal) {
240
+ return ONES[hundreds] + ' ' + HUNDRED + ' ' + tensOnesOrdinal
241
+ } else {
242
+ return ONES[hundreds] + ' hundredth'
243
+ }
244
+ }
245
+
246
+ return tensOnesOrdinal
247
+ }
248
+
249
+ function integerToOrdinal (n) {
250
+ if (n < 1000n) {
251
+ return buildOrdinalSegment(Number(n))
252
+ }
253
+
254
+ if (n < 1_000_000n) {
255
+ const thousands = Number(n / 1000n)
256
+ const remainder = Number(n % 1000n)
257
+
258
+ if (remainder === 0) {
259
+ return buildSegment(thousands).word + ' ' + SCALES[0] + 'th'
260
+ }
261
+
262
+ const { word: thousandsWord } = buildSegment(thousands)
263
+ return thousandsWord + ' ' + SCALES[0] + ' ' + buildOrdinalSegment(remainder)
264
+ }
265
+
266
+ return buildLargeOrdinal(n)
267
+ }
268
+
269
+ function buildLargeOrdinal (n) {
270
+ const segments = []
271
+ let temp = n
272
+ while (temp > 0n) {
273
+ segments.push(Number(temp % 1000n))
274
+ temp = temp / 1000n
275
+ }
276
+
277
+ let lowestNonZeroIdx = 0
278
+ for (let i = 0; i < segments.length; i++) {
279
+ if (segments[i] !== 0) {
280
+ lowestNonZeroIdx = i
281
+ break
282
+ }
283
+ }
284
+
285
+ let result = ''
286
+
287
+ for (let i = segments.length - 1; i >= 0; i--) {
288
+ const segment = segments[i]
289
+ if (segment === 0) continue
290
+
291
+ const isLowestSegment = (i === lowestNonZeroIdx)
292
+
293
+ if (result) result += ' '
294
+
295
+ if (isLowestSegment) {
296
+ if (i === 0) {
297
+ result += buildOrdinalSegment(segment)
298
+ } else {
299
+ result += buildSegment(segment).word + ' ' + SCALES[i - 1] + 'th'
300
+ }
301
+ } else {
302
+ result += buildSegment(segment).word
303
+ if (i > 0) {
304
+ result += ' ' + SCALES[i - 1]
305
+ }
306
+ }
307
+ }
308
+
309
+ return result
310
+ }
311
+
312
+ function toOrdinal (value) {
313
+ const integerPart = parseOrdinalValue(value)
314
+ return integerToOrdinal(integerPart)
315
+ }
316
+
317
+ // ============================================================================
318
+ // CURRENCY
319
+ // ============================================================================
320
+
321
+ function toCurrency (value, options) {
322
+ options = validateOptions(options)
323
+ const { isNegative, dollars: pesos, cents: centavos } = parseCurrencyValue(value)
324
+ const { and: useAnd = true } = options
325
+
326
+ let result = ''
327
+ if (isNegative) result = NEGATIVE + ' '
328
+
329
+ if (pesos > 0n || centavos === 0n) {
330
+ result += integerToWords(pesos)
331
+ result += ' ' + (pesos === 1n ? PESO : PESOS)
332
+ }
333
+
334
+ if (centavos > 0n) {
335
+ if (pesos > 0n) {
336
+ result += useAnd ? ' and ' : ' '
337
+ }
338
+ result += integerToWords(centavos)
339
+ result += ' ' + (centavos === 1n ? CENTAVO : CENTAVOS)
340
+ }
341
+
342
+ return result
343
+ }
344
+
345
+ export { toCardinal, toOrdinal, toCurrency }
package/src/en-PK.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Converts a numeric value to English words using Indian numbering.
3
+ *
4
+ * @param {number | string | bigint} value - The numeric value to convert
5
+ * @returns {string} The number in English words
6
+ * @throws {TypeError} If value is not a valid numeric type
7
+ * @throws {Error} If value is not a valid number format
8
+ *
9
+ * @example
10
+ * toCardinal(42) // 'forty-two'
11
+ * toCardinal(100000) // 'one lakh'
12
+ * toCardinal(10000000) // 'one crore'
13
+ * toCardinal(1234567) // 'twelve lakh thirty-four thousand five hundred and sixty-seven'
14
+ */
15
+ export function toCardinal(value: number | string | bigint): string;
16
+ /**
17
+ * Converts a numeric value to English ordinal words using Indian numbering.
18
+ *
19
+ * @param {number | string | bigint} value - The numeric value to convert (must be a positive integer)
20
+ * @returns {string} The number as ordinal words
21
+ * @throws {TypeError} If value is not a valid numeric type
22
+ * @throws {RangeError} If value is negative, zero, or has a decimal part
23
+ *
24
+ * @example
25
+ * toOrdinal(1) // 'first'
26
+ * toOrdinal(100000) // 'one lakhth'
27
+ * toOrdinal(100001) // 'one lakh first'
28
+ */
29
+ export function toOrdinal(value: number | string | bigint): string;
30
+ /**
31
+ * Converts a numeric value to Pakistani English currency words.
32
+ *
33
+ * @param {number | string | bigint} value - The currency amount to convert
34
+ * @param {Object} [options] - Optional configuration
35
+ * @param {boolean} [options.and=true] - Use "and" between rupees and paise
36
+ * @returns {string} The amount in Pakistani English currency words
37
+ * @throws {TypeError} If value is not a valid numeric type
38
+ * @throws {Error} If value is not a valid number format
39
+ *
40
+ * @example
41
+ * toCurrency(42.50) // 'forty-two rupees and fifty paise'
42
+ * toCurrency(100000) // 'one lakh rupees'
43
+ * toCurrency(1) // 'one rupee'
44
+ * toCurrency(0.50) // 'fifty paise'
45
+ * toCurrency(42.50, { and: false }) // 'forty-two rupees fifty paise'
46
+ */
47
+ export function toCurrency(value: number | string | bigint, options?: {
48
+ and?: boolean | undefined;
49
+ }): string;