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.
- package/CHANGELOG.md +44 -0
- package/LICENSE +1 -1
- package/README.md +64 -184
- package/dist/am-ET.js +2 -0
- package/dist/am-ET.umd.js +2 -0
- package/dist/am-Latn-ET.js +2 -0
- package/dist/am-Latn-ET.umd.js +2 -0
- package/dist/ar-SA.js +2 -0
- package/dist/ar-SA.umd.js +2 -0
- package/dist/az-AZ.js +2 -0
- package/dist/az-AZ.umd.js +2 -0
- package/dist/bn-BD.js +2 -0
- package/dist/bn-BD.umd.js +2 -0
- package/dist/cs-CZ.js +2 -0
- package/dist/cs-CZ.umd.js +2 -0
- package/dist/da-DK.js +2 -0
- package/dist/da-DK.umd.js +2 -0
- package/dist/de-DE.js +2 -0
- package/dist/de-DE.umd.js +2 -0
- package/dist/el-GR.js +2 -0
- package/dist/el-GR.umd.js +2 -0
- package/dist/en-AU.js +2 -0
- package/dist/en-AU.umd.js +2 -0
- package/dist/en-BD.js +2 -0
- package/dist/en-BD.umd.js +2 -0
- package/dist/en-CA.js +2 -0
- package/dist/en-CA.umd.js +2 -0
- package/dist/en-GB.js +2 -0
- package/dist/en-GB.umd.js +2 -0
- package/dist/en-GH.js +2 -0
- package/dist/en-GH.umd.js +2 -0
- package/dist/en-IE.js +2 -0
- package/dist/en-IE.umd.js +2 -0
- package/dist/en-IN.js +2 -0
- package/dist/en-IN.umd.js +2 -0
- package/dist/en-KE.js +2 -0
- package/dist/en-KE.umd.js +2 -0
- package/dist/en-MY.js +2 -0
- package/dist/en-MY.umd.js +2 -0
- package/dist/en-NG.js +2 -0
- package/dist/en-NG.umd.js +2 -0
- package/dist/en-NZ.js +2 -0
- package/dist/en-NZ.umd.js +2 -0
- package/dist/en-PH.js +2 -0
- package/dist/en-PH.umd.js +2 -0
- package/dist/en-PK.js +2 -0
- package/dist/en-PK.umd.js +2 -0
- package/dist/en-SG.js +2 -0
- package/dist/en-SG.umd.js +2 -0
- package/dist/en-US.js +2 -0
- package/dist/en-US.umd.js +2 -0
- package/dist/en-ZA.js +2 -0
- package/dist/en-ZA.umd.js +2 -0
- package/dist/es-ES.js +2 -0
- package/dist/es-ES.umd.js +2 -0
- package/dist/es-MX.js +2 -0
- package/dist/es-MX.umd.js +2 -0
- package/dist/es-US.js +2 -0
- package/dist/es-US.umd.js +2 -0
- package/dist/fa-IR.js +2 -0
- package/dist/fa-IR.umd.js +2 -0
- package/dist/fi-FI.js +2 -0
- package/dist/fi-FI.umd.js +2 -0
- package/dist/fil-PH.js +2 -0
- package/dist/fil-PH.umd.js +2 -0
- package/dist/fr-BE.js +2 -0
- package/dist/fr-BE.umd.js +2 -0
- package/dist/fr-FR.js +2 -0
- package/dist/fr-FR.umd.js +2 -0
- package/dist/gu-IN.js +2 -0
- package/dist/gu-IN.umd.js +2 -0
- package/dist/ha-NG.js +2 -0
- package/dist/ha-NG.umd.js +2 -0
- package/dist/hbo-IL.js +2 -0
- package/dist/hbo-IL.umd.js +2 -0
- package/dist/he-IL.js +2 -0
- package/dist/he-IL.umd.js +2 -0
- package/dist/hi-IN.js +2 -0
- package/dist/hi-IN.umd.js +2 -0
- package/dist/hr-HR.js +2 -0
- package/dist/hr-HR.umd.js +2 -0
- package/dist/hu-HU.js +2 -0
- package/dist/hu-HU.umd.js +2 -0
- package/dist/id-ID.js +2 -0
- package/dist/id-ID.umd.js +2 -0
- package/dist/it-IT.js +2 -0
- package/dist/it-IT.umd.js +2 -0
- package/dist/ja-JP.js +2 -0
- package/dist/ja-JP.umd.js +2 -0
- package/dist/ka-GE.js +2 -0
- package/dist/ka-GE.umd.js +2 -0
- package/dist/kn-IN.js +2 -0
- package/dist/kn-IN.umd.js +2 -0
- package/dist/ko-KR.js +2 -0
- package/dist/ko-KR.umd.js +2 -0
- package/dist/lt-LT.js +2 -0
- package/dist/lt-LT.umd.js +2 -0
- package/dist/lv-LV.js +2 -0
- package/dist/lv-LV.umd.js +2 -0
- package/dist/mr-IN.js +2 -0
- package/dist/mr-IN.umd.js +2 -0
- package/dist/ms-MY.js +2 -0
- package/dist/ms-MY.umd.js +2 -0
- package/dist/nb-NO.js +2 -0
- package/dist/nb-NO.umd.js +2 -0
- package/dist/nl-NL.js +2 -0
- package/dist/nl-NL.umd.js +2 -0
- package/dist/pa-IN.js +2 -0
- package/dist/pa-IN.umd.js +2 -0
- package/dist/pl-PL.js +2 -0
- package/dist/pl-PL.umd.js +2 -0
- package/dist/pt-PT.js +2 -0
- package/dist/pt-PT.umd.js +2 -0
- package/dist/ro-RO.js +2 -0
- package/dist/ro-RO.umd.js +2 -0
- package/dist/ru-RU.js +2 -0
- package/dist/ru-RU.umd.js +2 -0
- package/dist/sr-Cyrl-RS.js +2 -0
- package/dist/sr-Cyrl-RS.umd.js +2 -0
- package/dist/sr-Latn-RS.js +2 -0
- package/dist/sr-Latn-RS.umd.js +2 -0
- package/dist/sv-SE.js +2 -0
- package/dist/sv-SE.umd.js +2 -0
- package/dist/sw-KE.js +2 -0
- package/dist/sw-KE.umd.js +2 -0
- package/dist/ta-IN.js +2 -0
- package/dist/ta-IN.umd.js +2 -0
- package/dist/te-IN.js +2 -0
- package/dist/te-IN.umd.js +2 -0
- package/dist/th-TH.js +2 -0
- package/dist/th-TH.umd.js +2 -0
- package/dist/tr-TR.js +2 -0
- package/dist/tr-TR.umd.js +2 -0
- package/dist/uk-UA.js +2 -0
- package/dist/uk-UA.umd.js +2 -0
- package/dist/ur-PK.js +2 -0
- package/dist/ur-PK.umd.js +2 -0
- package/dist/vi-VN.js +2 -0
- package/dist/vi-VN.umd.js +2 -0
- package/dist/yo-NG.js +2 -0
- package/dist/yo-NG.umd.js +2 -0
- package/dist/zh-Hans-CN.js +2 -0
- package/dist/zh-Hans-CN.umd.js +2 -0
- package/dist/zh-Hant-TW.js +2 -0
- package/dist/zh-Hant-TW.umd.js +2 -0
- package/package.json +47 -82
- package/src/am-ET.d.ts +40 -0
- package/src/am-ET.js +269 -0
- package/src/am-Latn-ET.d.ts +35 -0
- package/src/am-Latn-ET.js +264 -0
- package/src/ar-SA.d.ts +49 -0
- package/{lib/languages/ar.js → src/ar-SA.js} +177 -15
- package/src/az-AZ.d.ts +37 -0
- package/src/az-AZ.js +312 -0
- package/src/bn-BD.d.ts +36 -0
- package/{lib/languages/bn.js → src/bn-BD.js} +110 -6
- package/src/cs-CZ.d.ts +49 -0
- package/{lib/languages/cs.js → src/cs-CZ.js} +240 -14
- package/src/da-DK.d.ts +44 -0
- package/{lib/languages/da.js → src/da-DK.js} +131 -11
- package/src/de-DE.d.ts +57 -0
- package/src/de-DE.js +603 -0
- package/src/el-GR.d.ts +40 -0
- package/src/el-GR.js +418 -0
- package/src/en-AU.d.ts +47 -0
- package/src/en-AU.js +423 -0
- package/src/en-BD.d.ts +49 -0
- package/src/en-BD.js +415 -0
- package/src/en-CA.d.ts +63 -0
- package/src/en-CA.js +518 -0
- package/src/en-GB.d.ts +56 -0
- package/src/en-GB.js +469 -0
- package/src/en-GH.d.ts +11 -0
- package/src/en-GH.js +345 -0
- package/src/en-IE.d.ts +56 -0
- package/src/en-IE.js +479 -0
- package/src/en-IN.d.ts +49 -0
- package/src/en-IN.js +415 -0
- package/src/en-KE.d.ts +11 -0
- package/src/en-KE.js +345 -0
- package/src/en-MY.d.ts +11 -0
- package/src/en-MY.js +347 -0
- package/src/en-NG.d.ts +56 -0
- package/src/en-NG.js +479 -0
- package/src/en-NZ.d.ts +11 -0
- package/{lib/languages/en.js → src/en-NZ.js} +164 -31
- package/src/en-PH.d.ts +11 -0
- package/src/en-PH.js +345 -0
- package/src/en-PK.d.ts +49 -0
- package/src/en-PK.js +415 -0
- package/src/en-SG.d.ts +11 -0
- package/src/en-SG.js +345 -0
- package/src/en-US.d.ts +63 -0
- package/src/en-US.js +516 -0
- package/src/en-ZA.d.ts +56 -0
- package/src/en-ZA.js +478 -0
- package/src/es-ES.d.ts +65 -0
- package/src/es-ES.js +541 -0
- package/src/es-MX.d.ts +58 -0
- package/{lib/languages/es.js → src/es-MX.js} +228 -18
- package/src/es-US.d.ts +58 -0
- package/src/es-US.js +446 -0
- package/src/fa-IR.d.ts +38 -0
- package/src/fa-IR.js +246 -0
- package/src/fi-FI.d.ts +46 -0
- package/{lib/languages/fi.js → src/fi-FI.js} +152 -11
- package/src/fil-PH.d.ts +37 -0
- package/{lib/languages/fil.js → src/fil-PH.js} +144 -8
- package/src/fr-BE.d.ts +49 -0
- package/{lib/languages → src}/fr-BE.js +175 -13
- package/src/fr-FR.d.ts +63 -0
- package/{lib/languages/fr.js → src/fr-FR.js} +182 -16
- package/src/gu-IN.d.ts +35 -0
- package/{lib/languages/gu.js → src/gu-IN.js} +115 -6
- package/src/ha-NG.d.ts +37 -0
- package/{lib/languages/ha.js → src/ha-NG.js} +107 -8
- package/src/hbo-IL.d.ts +39 -0
- package/{lib/languages/hbo.js → src/hbo-IL.js} +211 -19
- package/src/he-IL.d.ts +37 -0
- package/src/he-IL.js +537 -0
- package/src/hi-IN.d.ts +36 -0
- package/{lib/languages/hi.js → src/hi-IN.js} +116 -6
- package/src/hr-HR.d.ts +42 -0
- package/src/hr-HR.js +463 -0
- package/src/hu-HU.d.ts +38 -0
- package/{lib/languages/hu.js → src/hu-HU.js} +164 -6
- package/src/id-ID.d.ts +38 -0
- package/{lib/languages/id.js → src/id-ID.js} +99 -8
- package/src/it-IT.d.ts +59 -0
- package/{lib/languages/it.js → src/it-IT.js} +179 -15
- package/src/ja-JP.d.ts +49 -0
- package/{lib/languages/ja.js → src/ja-JP.js} +111 -12
- package/src/ka-GE.d.ts +44 -0
- package/{lib/languages/ka.js → src/ka-GE.js} +113 -11
- package/src/kn-IN.d.ts +35 -0
- package/{lib/languages/kn.js → src/kn-IN.js} +115 -6
- package/src/ko-KR.d.ts +45 -0
- package/{lib/languages/ko.js → src/ko-KR.js} +94 -12
- package/src/lt-LT.d.ts +49 -0
- package/src/lt-LT.js +543 -0
- package/src/lv-LV.d.ts +49 -0
- package/src/lv-LV.js +595 -0
- package/src/mr-IN.d.ts +36 -0
- package/{lib/languages/mr.js → src/mr-IN.js} +116 -6
- package/src/ms-MY.d.ts +37 -0
- package/{lib/languages/ms.js → src/ms-MY.js} +111 -8
- package/src/nb-NO.d.ts +44 -0
- package/{lib/languages/nb.js → src/nb-NO.js} +153 -11
- package/src/nl-NL.d.ts +54 -0
- package/{lib/languages/nl.js → src/nl-NL.js} +260 -18
- package/src/pa-IN.d.ts +36 -0
- package/{lib/languages/pa.js → src/pa-IN.js} +116 -6
- package/src/pl-PL.d.ts +55 -0
- package/src/pl-PL.js +585 -0
- package/src/pt-PT.d.ts +45 -0
- package/{lib/languages/pt.js → src/pt-PT.js} +234 -12
- package/src/ro-RO.d.ts +44 -0
- package/{lib/languages/ro.js → src/ro-RO.js} +212 -18
- package/src/ru-RU.d.ts +50 -0
- package/src/ru-RU.js +535 -0
- package/src/sr-Cyrl-RS.d.ts +49 -0
- package/src/sr-Cyrl-RS.js +503 -0
- package/src/sr-Latn-RS.d.ts +49 -0
- package/src/sr-Latn-RS.js +503 -0
- package/src/sv-SE.d.ts +44 -0
- package/{lib/languages/sv.js → src/sv-SE.js} +136 -11
- package/src/sw-KE.d.ts +37 -0
- package/{lib/languages/sw.js → src/sw-KE.js} +117 -6
- package/src/ta-IN.d.ts +35 -0
- package/{lib/languages/ta.js → src/ta-IN.js} +109 -6
- package/src/te-IN.d.ts +35 -0
- package/{lib/languages/te.js → src/te-IN.js} +115 -6
- package/src/th-TH.d.ts +38 -0
- package/{lib/languages/th.js → src/th-TH.js} +99 -6
- package/src/tr-TR.d.ts +48 -0
- package/{lib/languages/tr.js → src/tr-TR.js} +168 -23
- package/src/uk-UA.d.ts +42 -0
- package/src/uk-UA.js +463 -0
- package/src/ur-PK.d.ts +36 -0
- package/{lib/languages/ur.js → src/ur-PK.js} +116 -6
- package/src/utils/expand-scientific.d.ts +32 -0
- package/src/utils/expand-scientific.js +65 -0
- package/src/utils/parse-cardinal.d.ts +14 -0
- package/{lib/utils/parse-numeric.js → src/utils/parse-cardinal.js} +14 -44
- package/src/utils/parse-currency.d.ts +14 -0
- package/src/utils/parse-currency.js +91 -0
- package/src/utils/parse-ordinal.d.ts +10 -0
- package/src/utils/parse-ordinal.js +103 -0
- package/src/vi-VN.d.ts +48 -0
- package/{lib/languages/vi.js → src/vi-VN.js} +102 -11
- package/src/yo-NG.d.ts +37 -0
- package/{lib/languages/yo.js → src/yo-NG.js} +109 -9
- package/src/zh-Hans-CN.d.ts +48 -0
- package/{lib/languages/zh-Hans.js → src/zh-Hans-CN.js} +140 -8
- package/src/zh-Hant-TW.d.ts +50 -0
- package/{lib/languages/zh-Hant.js → src/zh-Hant-TW.js} +139 -8
- package/dist/languages/am-Latn.js +0 -3
- package/dist/languages/am-Latn.js.map +0 -1
- package/dist/languages/am.js +0 -3
- package/dist/languages/am.js.map +0 -1
- package/dist/languages/ar.js +0 -3
- package/dist/languages/ar.js.map +0 -1
- package/dist/languages/az.js +0 -3
- package/dist/languages/az.js.map +0 -1
- package/dist/languages/bn.js +0 -3
- package/dist/languages/bn.js.map +0 -1
- package/dist/languages/cs.js +0 -3
- package/dist/languages/cs.js.map +0 -1
- package/dist/languages/da.js +0 -3
- package/dist/languages/da.js.map +0 -1
- package/dist/languages/de.js +0 -3
- package/dist/languages/de.js.map +0 -1
- package/dist/languages/el.js +0 -3
- package/dist/languages/el.js.map +0 -1
- package/dist/languages/en.js +0 -3
- package/dist/languages/en.js.map +0 -1
- package/dist/languages/es.js +0 -3
- package/dist/languages/es.js.map +0 -1
- package/dist/languages/fa.js +0 -3
- package/dist/languages/fa.js.map +0 -1
- package/dist/languages/fi.js +0 -3
- package/dist/languages/fi.js.map +0 -1
- package/dist/languages/fil.js +0 -3
- package/dist/languages/fil.js.map +0 -1
- package/dist/languages/fr-BE.js +0 -3
- package/dist/languages/fr-BE.js.map +0 -1
- package/dist/languages/fr.js +0 -3
- package/dist/languages/fr.js.map +0 -1
- package/dist/languages/gu.js +0 -3
- package/dist/languages/gu.js.map +0 -1
- package/dist/languages/ha.js +0 -3
- package/dist/languages/ha.js.map +0 -1
- package/dist/languages/hbo.js +0 -3
- package/dist/languages/hbo.js.map +0 -1
- package/dist/languages/he.js +0 -3
- package/dist/languages/he.js.map +0 -1
- package/dist/languages/hi.js +0 -3
- package/dist/languages/hi.js.map +0 -1
- package/dist/languages/hr.js +0 -3
- package/dist/languages/hr.js.map +0 -1
- package/dist/languages/hu.js +0 -3
- package/dist/languages/hu.js.map +0 -1
- package/dist/languages/id.js +0 -3
- package/dist/languages/id.js.map +0 -1
- package/dist/languages/it.js +0 -3
- package/dist/languages/it.js.map +0 -1
- package/dist/languages/ja.js +0 -3
- package/dist/languages/ja.js.map +0 -1
- package/dist/languages/ka.js +0 -3
- package/dist/languages/ka.js.map +0 -1
- package/dist/languages/kn.js +0 -3
- package/dist/languages/kn.js.map +0 -1
- package/dist/languages/ko.js +0 -3
- package/dist/languages/ko.js.map +0 -1
- package/dist/languages/lt.js +0 -3
- package/dist/languages/lt.js.map +0 -1
- package/dist/languages/lv.js +0 -3
- package/dist/languages/lv.js.map +0 -1
- package/dist/languages/mr.js +0 -3
- package/dist/languages/mr.js.map +0 -1
- package/dist/languages/ms.js +0 -3
- package/dist/languages/ms.js.map +0 -1
- package/dist/languages/nb.js +0 -3
- package/dist/languages/nb.js.map +0 -1
- package/dist/languages/nl.js +0 -3
- package/dist/languages/nl.js.map +0 -1
- package/dist/languages/pa.js +0 -3
- package/dist/languages/pa.js.map +0 -1
- package/dist/languages/pl.js +0 -3
- package/dist/languages/pl.js.map +0 -1
- package/dist/languages/pt.js +0 -3
- package/dist/languages/pt.js.map +0 -1
- package/dist/languages/ro.js +0 -3
- package/dist/languages/ro.js.map +0 -1
- package/dist/languages/ru.js +0 -3
- package/dist/languages/ru.js.map +0 -1
- package/dist/languages/sr-Cyrl.js +0 -3
- package/dist/languages/sr-Cyrl.js.map +0 -1
- package/dist/languages/sr-Latn.js +0 -3
- package/dist/languages/sr-Latn.js.map +0 -1
- package/dist/languages/sv.js +0 -3
- package/dist/languages/sv.js.map +0 -1
- package/dist/languages/sw.js +0 -3
- package/dist/languages/sw.js.map +0 -1
- package/dist/languages/ta.js +0 -3
- package/dist/languages/ta.js.map +0 -1
- package/dist/languages/te.js +0 -3
- package/dist/languages/te.js.map +0 -1
- package/dist/languages/th.js +0 -3
- package/dist/languages/th.js.map +0 -1
- package/dist/languages/tr.js +0 -3
- package/dist/languages/tr.js.map +0 -1
- package/dist/languages/uk.js +0 -3
- package/dist/languages/uk.js.map +0 -1
- package/dist/languages/ur.js +0 -3
- package/dist/languages/ur.js.map +0 -1
- package/dist/languages/vi.js +0 -3
- package/dist/languages/vi.js.map +0 -1
- package/dist/languages/yo.js +0 -3
- package/dist/languages/yo.js.map +0 -1
- package/dist/languages/zh-Hans.js +0 -3
- package/dist/languages/zh-Hans.js.map +0 -1
- package/dist/languages/zh-Hant.js +0 -3
- package/dist/languages/zh-Hant.js.map +0 -1
- package/dist/n2words.js +0 -3
- package/dist/n2words.js.map +0 -1
- package/lib/languages/am-Latn.d.ts +0 -7
- package/lib/languages/am-Latn.js +0 -159
- package/lib/languages/am.d.ts +0 -7
- package/lib/languages/am.js +0 -159
- package/lib/languages/ar.d.ts +0 -17
- package/lib/languages/az.d.ts +0 -7
- package/lib/languages/az.js +0 -171
- package/lib/languages/bn.d.ts +0 -7
- package/lib/languages/cs.d.ts +0 -18
- package/lib/languages/da.d.ts +0 -14
- package/lib/languages/de.d.ts +0 -17
- package/lib/languages/de.js +0 -320
- package/lib/languages/el.d.ts +0 -14
- package/lib/languages/el.js +0 -236
- package/lib/languages/en.d.ts +0 -17
- package/lib/languages/es.d.ts +0 -21
- package/lib/languages/fa.d.ts +0 -7
- package/lib/languages/fa.js +0 -134
- package/lib/languages/fi.d.ts +0 -14
- package/lib/languages/fil.d.ts +0 -7
- package/lib/languages/fr-BE.d.ts +0 -11
- package/lib/languages/fr.d.ts +0 -21
- package/lib/languages/gu.d.ts +0 -7
- package/lib/languages/ha.d.ts +0 -7
- package/lib/languages/hbo.d.ts +0 -13
- package/lib/languages/he.d.ts +0 -13
- package/lib/languages/he.js +0 -265
- package/lib/languages/hi.d.ts +0 -7
- package/lib/languages/hr.d.ts +0 -11
- package/lib/languages/hr.js +0 -224
- package/lib/languages/hu.d.ts +0 -7
- package/lib/languages/id.d.ts +0 -7
- package/lib/languages/it.d.ts +0 -19
- package/lib/languages/ja.d.ts +0 -17
- package/lib/languages/ka.d.ts +0 -17
- package/lib/languages/kn.d.ts +0 -7
- package/lib/languages/ko.d.ts +0 -14
- package/lib/languages/lt.d.ts +0 -18
- package/lib/languages/lt.js +0 -301
- package/lib/languages/lv.d.ts +0 -18
- package/lib/languages/lv.js +0 -312
- package/lib/languages/mr.d.ts +0 -7
- package/lib/languages/ms.d.ts +0 -7
- package/lib/languages/nb.d.ts +0 -14
- package/lib/languages/nl.d.ts +0 -26
- package/lib/languages/pa.d.ts +0 -7
- package/lib/languages/pl.d.ts +0 -22
- package/lib/languages/pl.js +0 -317
- package/lib/languages/pt.d.ts +0 -17
- package/lib/languages/ro.d.ts +0 -18
- package/lib/languages/ru.d.ts +0 -11
- package/lib/languages/ru.js +0 -245
- package/lib/languages/sr-Cyrl.d.ts +0 -11
- package/lib/languages/sr-Cyrl.js +0 -221
- package/lib/languages/sr-Latn.d.ts +0 -11
- package/lib/languages/sr-Latn.js +0 -221
- package/lib/languages/sv.d.ts +0 -14
- package/lib/languages/sw.d.ts +0 -7
- package/lib/languages/ta.d.ts +0 -7
- package/lib/languages/te.d.ts +0 -7
- package/lib/languages/th.d.ts +0 -7
- package/lib/languages/tr.d.ts +0 -18
- package/lib/languages/uk.d.ts +0 -11
- package/lib/languages/uk.js +0 -224
- package/lib/languages/ur.d.ts +0 -7
- package/lib/languages/vi.d.ts +0 -17
- package/lib/languages/yo.d.ts +0 -7
- package/lib/languages/zh-Hans.d.ts +0 -11
- package/lib/languages/zh-Hant.d.ts +0 -11
- package/lib/n2words.d.ts +0 -55
- package/lib/n2words.js +0 -126
- package/lib/utils/parse-numeric.d.ts +0 -17
- /package/{lib → src}/utils/is-plain-object.d.ts +0 -0
- /package/{lib → src}/utils/is-plain-object.js +0 -0
- /package/{lib → src}/utils/validate-options.d.ts +0 -0
- /package/{lib → src}/utils/validate-options.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* French language converter
|
|
2
|
+
* French (France) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: fr-FR | French as used in France
|
|
5
5
|
*
|
|
6
6
|
* French-specific rules:
|
|
7
7
|
* - Vigesimal patterns: 70 = soixante-dix, 80 = quatre-vingts, 90 = quatre-vingt-dix
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
* - Omit "un" before mille
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { parseCardinalValue } from './utils/parse-cardinal.js'
|
|
15
|
+
import { parseCurrencyValue } from './utils/parse-currency.js'
|
|
16
|
+
import { parseOrdinalValue } from './utils/parse-ordinal.js'
|
|
17
|
+
import { validateOptions } from './utils/validate-options.js'
|
|
16
18
|
|
|
17
19
|
// ============================================================================
|
|
18
20
|
// Vocabulary (module-level constants)
|
|
@@ -32,6 +34,25 @@ const ZERO = 'zéro'
|
|
|
32
34
|
const NEGATIVE = 'moins'
|
|
33
35
|
const DECIMAL_SEP = 'virgule'
|
|
34
36
|
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Ordinal Vocabulary
|
|
39
|
+
// ============================================================================
|
|
40
|
+
|
|
41
|
+
// Ordinal suffix
|
|
42
|
+
const ORDINAL_SUFFIX = 'ième'
|
|
43
|
+
|
|
44
|
+
// Special ordinals
|
|
45
|
+
const PREMIER = 'premier'
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Currency Vocabulary (Euro)
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
const EURO = 'euro'
|
|
52
|
+
const EUROS = 'euros'
|
|
53
|
+
const CENTIME = 'centime'
|
|
54
|
+
const CENTIMES = 'centimes'
|
|
55
|
+
|
|
35
56
|
// ============================================================================
|
|
36
57
|
// Segment Building
|
|
37
58
|
// ============================================================================
|
|
@@ -44,7 +65,7 @@ function buildSegment (n) {
|
|
|
44
65
|
if (n === 0) return { word: '', endsWithCents: false, endsWithVingts: false }
|
|
45
66
|
|
|
46
67
|
const tensOnes = n % 100
|
|
47
|
-
const hundreds = Math.
|
|
68
|
+
const hundreds = Math.trunc(n / 100)
|
|
48
69
|
|
|
49
70
|
const parts = []
|
|
50
71
|
let endsWithCents = false
|
|
@@ -84,7 +105,7 @@ function buildSegment (n) {
|
|
|
84
105
|
parts.push(TEENS[tensOnes - 10])
|
|
85
106
|
} else if (tensOnes < 70) {
|
|
86
107
|
// 20-69: standard tens + ones
|
|
87
|
-
const t = Math.
|
|
108
|
+
const t = Math.trunc(tensOnes / 10)
|
|
88
109
|
const o = tensOnes % 10
|
|
89
110
|
if (o === 0) {
|
|
90
111
|
parts.push(TENS[t])
|
|
@@ -324,26 +345,171 @@ function decimalPartToWords (decimalPart, withHyphen) {
|
|
|
324
345
|
* @throws {Error} If value is not a valid number format
|
|
325
346
|
*
|
|
326
347
|
* @example
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
348
|
+
* toCardinal(21) // 'vingt et un'
|
|
349
|
+
* toCardinal(80) // 'quatre-vingts'
|
|
350
|
+
* toCardinal(1000000) // 'un million'
|
|
330
351
|
*/
|
|
331
|
-
function
|
|
352
|
+
function toCardinal (value, options) {
|
|
332
353
|
options = validateOptions(options)
|
|
333
|
-
const { isNegative, integerPart, decimalPart } =
|
|
334
|
-
|
|
354
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
355
|
+
|
|
356
|
+
// Apply option defaults
|
|
357
|
+
const { withHyphenSeparator = false } = options
|
|
335
358
|
|
|
336
359
|
let result = ''
|
|
337
|
-
const sep =
|
|
360
|
+
const sep = withHyphenSeparator ? '-' : ' '
|
|
338
361
|
|
|
339
362
|
if (isNegative) {
|
|
340
363
|
result = NEGATIVE + sep
|
|
341
364
|
}
|
|
342
365
|
|
|
343
|
-
result += integerToWords(integerPart,
|
|
366
|
+
result += integerToWords(integerPart, withHyphenSeparator)
|
|
344
367
|
|
|
345
368
|
if (decimalPart) {
|
|
346
|
-
result += sep + DECIMAL_SEP + sep + decimalPartToWords(decimalPart,
|
|
369
|
+
result += sep + DECIMAL_SEP + sep + decimalPartToWords(decimalPart, withHyphenSeparator)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return result
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ============================================================================
|
|
376
|
+
// ORDINAL: toOrdinal(value)
|
|
377
|
+
// ============================================================================
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Converts a cardinal number word to its ordinal form.
|
|
381
|
+
* Rules:
|
|
382
|
+
* - 1 → premier (special case)
|
|
383
|
+
* - Drop final -e before adding -ième (quatre → quatrième)
|
|
384
|
+
* - cinq → cinquième (add -u- before -ième)
|
|
385
|
+
* - neuf → neuvième (f → v before -ième)
|
|
386
|
+
*
|
|
387
|
+
* @param {string} cardinalWord - Cardinal word to convert
|
|
388
|
+
* @returns {string} Ordinal form
|
|
389
|
+
*/
|
|
390
|
+
function cardinalToOrdinal (cardinalWord) {
|
|
391
|
+
// Handle special endings
|
|
392
|
+
if (cardinalWord.endsWith('cinq')) {
|
|
393
|
+
// cinq → cinquième (add 'u')
|
|
394
|
+
return cardinalWord + 'u' + ORDINAL_SUFFIX
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (cardinalWord.endsWith('neuf')) {
|
|
398
|
+
// neuf → neuvième (f → v)
|
|
399
|
+
return cardinalWord.slice(0, -1) + 'v' + ORDINAL_SUFFIX
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Drop plural -s from cents/vingts/millions/etc. (quatre-vingts → quatre-vingtième)
|
|
403
|
+
// Note: "trois", "six" also end in s but that's not a plural
|
|
404
|
+
if (cardinalWord.endsWith('cents') ||
|
|
405
|
+
cardinalWord.endsWith('vingts') ||
|
|
406
|
+
cardinalWord.endsWith('millions') ||
|
|
407
|
+
cardinalWord.endsWith('milliards') ||
|
|
408
|
+
cardinalWord.endsWith('billions') ||
|
|
409
|
+
cardinalWord.endsWith('billiards') ||
|
|
410
|
+
cardinalWord.endsWith('trillions') ||
|
|
411
|
+
cardinalWord.endsWith('trilliards') ||
|
|
412
|
+
cardinalWord.endsWith('quadrillions') ||
|
|
413
|
+
cardinalWord.endsWith('quadrilliards')) {
|
|
414
|
+
return cardinalWord.slice(0, -1) + ORDINAL_SUFFIX
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Drop final -e before adding -ième (quatre → quatrième)
|
|
418
|
+
if (cardinalWord.endsWith('e')) {
|
|
419
|
+
return cardinalWord.slice(0, -1) + ORDINAL_SUFFIX
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Default: just add -ième
|
|
423
|
+
return cardinalWord + ORDINAL_SUFFIX
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Converts a positive integer to French ordinal words.
|
|
428
|
+
*
|
|
429
|
+
* @param {bigint} n - Positive integer
|
|
430
|
+
* @returns {string} French ordinal words
|
|
431
|
+
*/
|
|
432
|
+
function integerToOrdinal (n) {
|
|
433
|
+
// Special case: 1 → premier
|
|
434
|
+
if (n === 1n) {
|
|
435
|
+
return PREMIER
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Get cardinal form and convert to ordinal
|
|
439
|
+
const cardinalWord = integerToWords(n, false)
|
|
440
|
+
return cardinalToOrdinal(cardinalWord)
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Converts a numeric value to French ordinal words.
|
|
445
|
+
*
|
|
446
|
+
* French ordinals: premier (1st), then cardinal + ième.
|
|
447
|
+
* Special rules: quatre→quatrième, cinq→cinquième, neuf→neuvième.
|
|
448
|
+
*
|
|
449
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
450
|
+
* @returns {string} The number as ordinal words
|
|
451
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
452
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* toOrdinal(1) // 'premier'
|
|
456
|
+
* toOrdinal(2) // 'deuxième'
|
|
457
|
+
* toOrdinal(4) // 'quatrième'
|
|
458
|
+
* toOrdinal(5) // 'cinquième'
|
|
459
|
+
* toOrdinal(9) // 'neuvième'
|
|
460
|
+
* toOrdinal(21) // 'vingt et unième'
|
|
461
|
+
* toOrdinal(100) // 'centième'
|
|
462
|
+
* toOrdinal(1000) // 'millième'
|
|
463
|
+
*/
|
|
464
|
+
function toOrdinal (value) {
|
|
465
|
+
const integerPart = parseOrdinalValue(value)
|
|
466
|
+
return integerToOrdinal(integerPart)
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// ============================================================================
|
|
470
|
+
// CURRENCY: toCurrency(value, options?)
|
|
471
|
+
// ============================================================================
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Converts a numeric value to French currency words (Euro).
|
|
475
|
+
*
|
|
476
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
477
|
+
* @param {Object} [options] - Optional configuration
|
|
478
|
+
* @param {boolean} [options.and=true] - Use "et" between euros and centimes
|
|
479
|
+
* @returns {string} The amount in French currency words
|
|
480
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
481
|
+
* @throws {Error} If value is not a valid number format
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* toCurrency(42.50) // 'quarante-deux euros et cinquante centimes'
|
|
485
|
+
* toCurrency(1) // 'un euro'
|
|
486
|
+
* toCurrency(0.99) // 'quatre-vingt-dix-neuf centimes'
|
|
487
|
+
* toCurrency(0.01) // 'un centime'
|
|
488
|
+
* toCurrency(42.50, { and: false }) // 'quarante-deux euros cinquante centimes'
|
|
489
|
+
*/
|
|
490
|
+
function toCurrency (value, options) {
|
|
491
|
+
options = validateOptions(options)
|
|
492
|
+
const { isNegative, dollars: euros, cents: centimes } = parseCurrencyValue(value)
|
|
493
|
+
const { and: useAnd = true } = options
|
|
494
|
+
|
|
495
|
+
// Build result
|
|
496
|
+
let result = ''
|
|
497
|
+
if (isNegative) result = NEGATIVE + ' '
|
|
498
|
+
|
|
499
|
+
// Euros part
|
|
500
|
+
if (euros > 0n || centimes === 0n) {
|
|
501
|
+
result += integerToWords(euros, false)
|
|
502
|
+
// In French, 0 and 1 are singular: "zéro euro", "un euro"
|
|
503
|
+
result += ' ' + (euros <= 1n ? EURO : EUROS)
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// Centimes part
|
|
507
|
+
if (centimes > 0n) {
|
|
508
|
+
if (euros > 0n) {
|
|
509
|
+
result += useAnd ? ' et ' : ' '
|
|
510
|
+
}
|
|
511
|
+
result += integerToWords(centimes, false)
|
|
512
|
+
result += ' ' + (centimes === 1n ? CENTIME : CENTIMES)
|
|
347
513
|
}
|
|
348
514
|
|
|
349
515
|
return result
|
|
@@ -353,4 +519,4 @@ function toWords (value, options) {
|
|
|
353
519
|
// Public API
|
|
354
520
|
// ============================================================================
|
|
355
521
|
|
|
356
|
-
export {
|
|
522
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/gu-IN.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Gujarati words.
|
|
3
|
+
*
|
|
4
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
5
|
+
* @returns {string} The number in Gujarati words
|
|
6
|
+
*/
|
|
7
|
+
export function toCardinal(value: number | string | bigint): string;
|
|
8
|
+
/**
|
|
9
|
+
* Converts a numeric value to Gujarati 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) // 'પહેલું'
|
|
18
|
+
* toOrdinal(2) // 'બીજું'
|
|
19
|
+
* toOrdinal(10) // 'દસમું'
|
|
20
|
+
*/
|
|
21
|
+
export function toOrdinal(value: number | string | bigint): string;
|
|
22
|
+
/**
|
|
23
|
+
* Converts a numeric value to Gujarati currency words (Indian Rupee).
|
|
24
|
+
*
|
|
25
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
26
|
+
* @returns {string} The amount in Gujarati currency words
|
|
27
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
28
|
+
* @throws {Error} If value is not a valid number format
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* toCurrency(42.50) // 'બેતાળીસ રૂપિયા પચાસ પૈસા'
|
|
32
|
+
* toCurrency(1) // 'એક રૂપિયો'
|
|
33
|
+
* toCurrency(0.01) // 'એક પૈસો'
|
|
34
|
+
*/
|
|
35
|
+
export function toCurrency(value: number | string | bigint): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gujarati language converter
|
|
2
|
+
* Gujarati (India) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: gu-IN | Gujarati as used in India
|
|
5
5
|
*
|
|
6
6
|
* Key features:
|
|
7
7
|
* - Indian numbering system (હજાર, લાખ, કરોડ)
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* - Per-digit decimal reading
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { parseCardinalValue } from './utils/parse-cardinal.js'
|
|
15
|
+
import { parseCurrencyValue } from './utils/parse-currency.js'
|
|
16
|
+
import { parseOrdinalValue } from './utils/parse-ordinal.js'
|
|
15
17
|
|
|
16
18
|
// ============================================================================
|
|
17
19
|
// Vocabulary
|
|
@@ -22,6 +24,28 @@ const NEGATIVE = 'ઋણ'
|
|
|
22
24
|
const DECIMAL_SEP = 'દશાંશ'
|
|
23
25
|
const HUNDRED = 'સો'
|
|
24
26
|
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Ordinal Vocabulary
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
// Ordinal suffix (adds to cardinal for numbers >= 7)
|
|
32
|
+
const ORDINAL_SUFFIX = 'મું'
|
|
33
|
+
|
|
34
|
+
// Special ordinals for first few numbers (1-6 have irregular forms)
|
|
35
|
+
const ORDINAL_SPECIAL = ['', 'પહેલું', 'બીજું', 'ત્રીજું', 'ચોથું', 'પાંચમું', 'છઠ્ઠું']
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Currency Vocabulary (Indian Rupee)
|
|
39
|
+
// ============================================================================
|
|
40
|
+
|
|
41
|
+
// Rupee: singular/plural
|
|
42
|
+
const RUPEE = 'રૂપિયો'
|
|
43
|
+
const RUPEES = 'રૂપિયા'
|
|
44
|
+
|
|
45
|
+
// Paisa: singular/plural
|
|
46
|
+
const PAISA = 'પૈસો'
|
|
47
|
+
const PAISE = 'પૈસા'
|
|
48
|
+
|
|
25
49
|
const BELOW_HUNDRED = [
|
|
26
50
|
'શૂન્ય', 'એક', 'બે', 'ત્રણ', 'ચાર', 'પાંચ', 'છ', 'સાત', 'આઠ', 'નવ',
|
|
27
51
|
'દસ', 'અગિયાર', 'બાર', 'તેર', 'ચૌદ', 'પંદર', 'સોળ', 'સત્તર', 'અઢાર', 'ઓગણીસ',
|
|
@@ -125,8 +149,8 @@ function decimalPartToWords (decimalPart) {
|
|
|
125
149
|
* @param {number | string | bigint} value - The numeric value to convert
|
|
126
150
|
* @returns {string} The number in Gujarati words
|
|
127
151
|
*/
|
|
128
|
-
function
|
|
129
|
-
const { isNegative, integerPart, decimalPart } =
|
|
152
|
+
function toCardinal (value) {
|
|
153
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
130
154
|
|
|
131
155
|
let result = ''
|
|
132
156
|
|
|
@@ -143,8 +167,93 @@ function toWords (value) {
|
|
|
143
167
|
return result
|
|
144
168
|
}
|
|
145
169
|
|
|
170
|
+
// ============================================================================
|
|
171
|
+
// ORDINAL: toOrdinal(value)
|
|
172
|
+
// ============================================================================
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Converts a positive integer to Gujarati ordinal words.
|
|
176
|
+
*
|
|
177
|
+
* Gujarati ordinals: First 6 are irregular, then add -મું suffix.
|
|
178
|
+
*
|
|
179
|
+
* @param {bigint} n - Positive integer to convert
|
|
180
|
+
* @returns {string} Gujarati ordinal words
|
|
181
|
+
*/
|
|
182
|
+
function integerToOrdinal (n) {
|
|
183
|
+
// Special ordinals for 1-6
|
|
184
|
+
if (n >= 1n && n <= 6n) {
|
|
185
|
+
return ORDINAL_SPECIAL[Number(n)]
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// For 7 and above, add suffix to cardinal
|
|
189
|
+
const cardinal = integerToWords(n)
|
|
190
|
+
return cardinal + ORDINAL_SUFFIX
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Converts a numeric value to Gujarati ordinal words.
|
|
195
|
+
*
|
|
196
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
197
|
+
* @returns {string} The number as ordinal words
|
|
198
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
199
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* toOrdinal(1) // 'પહેલું'
|
|
203
|
+
* toOrdinal(2) // 'બીજું'
|
|
204
|
+
* toOrdinal(10) // 'દસમું'
|
|
205
|
+
*/
|
|
206
|
+
function toOrdinal (value) {
|
|
207
|
+
const integerPart = parseOrdinalValue(value)
|
|
208
|
+
return integerToOrdinal(integerPart)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ============================================================================
|
|
212
|
+
// CURRENCY: toCurrency(value, options?)
|
|
213
|
+
// ============================================================================
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Converts a numeric value to Gujarati currency words (Indian Rupee).
|
|
217
|
+
*
|
|
218
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
219
|
+
* @returns {string} The amount in Gujarati currency words
|
|
220
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
221
|
+
* @throws {Error} If value is not a valid number format
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* toCurrency(42.50) // 'બેતાળીસ રૂપિયા પચાસ પૈસા'
|
|
225
|
+
* toCurrency(1) // 'એક રૂપિયો'
|
|
226
|
+
* toCurrency(0.01) // 'એક પૈસો'
|
|
227
|
+
*/
|
|
228
|
+
function toCurrency (value) {
|
|
229
|
+
const { isNegative, dollars: rupees, cents: paise } = parseCurrencyValue(value)
|
|
230
|
+
|
|
231
|
+
// Build result
|
|
232
|
+
let result = ''
|
|
233
|
+
if (isNegative) result = NEGATIVE + ' '
|
|
234
|
+
|
|
235
|
+
// Rupees part - show if non-zero, or if no paise
|
|
236
|
+
if (rupees > 0n || paise === 0n) {
|
|
237
|
+
result += integerToWords(rupees)
|
|
238
|
+
// Singular for 1 rupee, plural otherwise
|
|
239
|
+
result += ' ' + (rupees === 1n ? RUPEE : RUPEES)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Paise part
|
|
243
|
+
if (paise > 0n) {
|
|
244
|
+
if (rupees > 0n) {
|
|
245
|
+
result += ' '
|
|
246
|
+
}
|
|
247
|
+
result += integerToWords(paise)
|
|
248
|
+
// Singular for 1 paisa, plural otherwise
|
|
249
|
+
result += ' ' + (paise === 1n ? PAISA : PAISE)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return result
|
|
253
|
+
}
|
|
254
|
+
|
|
146
255
|
// ============================================================================
|
|
147
256
|
// Exports
|
|
148
257
|
// ============================================================================
|
|
149
258
|
|
|
150
|
-
export {
|
|
259
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/ha-NG.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Hausa words.
|
|
3
|
+
*
|
|
4
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
5
|
+
* @returns {string} The number in Hausa words
|
|
6
|
+
*/
|
|
7
|
+
export function toCardinal(value: number | string | bigint): string;
|
|
8
|
+
/**
|
|
9
|
+
* Converts a numeric value to Hausa 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) // 'na farko'
|
|
18
|
+
* toOrdinal(2) // 'na biyu'
|
|
19
|
+
* toOrdinal(10) // 'na goma'
|
|
20
|
+
*/
|
|
21
|
+
export function toOrdinal(value: number | string | bigint): string;
|
|
22
|
+
/**
|
|
23
|
+
* Converts a numeric value to Hausa currency words (Nigerian Naira).
|
|
24
|
+
*
|
|
25
|
+
* Uses naira and kobo (100 kobo = 1 naira).
|
|
26
|
+
*
|
|
27
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
28
|
+
* @returns {string} The amount in Hausa 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) // 'arba'in da biyu naira'
|
|
34
|
+
* toCurrency(1.50) // 'ɗaya naira da hamsin kobo'
|
|
35
|
+
* toCurrency(-5) // 'babu biyar naira'
|
|
36
|
+
*/
|
|
37
|
+
export function toCurrency(value: number | string | bigint): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hausa language converter
|
|
2
|
+
* Hausa (Nigeria) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: ha-NG | Hausa as used in Nigeria
|
|
5
5
|
*
|
|
6
6
|
* Key features:
|
|
7
7
|
* - Authentic Boko orthography with ɗ (hooked d) and ' (glottal stop)
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
* - Per-digit decimal reading
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { parseCardinalValue } from './utils/parse-cardinal.js'
|
|
17
|
+
import { parseCurrencyValue } from './utils/parse-currency.js'
|
|
18
|
+
import { parseOrdinalValue } from './utils/parse-ordinal.js'
|
|
17
19
|
|
|
18
20
|
// ============================================================================
|
|
19
21
|
// Vocabulary
|
|
@@ -34,6 +36,22 @@ const DECIMAL_SEP = 'digo'
|
|
|
34
36
|
// Short scale
|
|
35
37
|
const SCALE_WORDS = ['', THOUSAND, 'miliyan', 'biliyan']
|
|
36
38
|
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Ordinal Vocabulary
|
|
41
|
+
// ============================================================================
|
|
42
|
+
|
|
43
|
+
// Hausa ordinals: "na" + cardinal (na ɗaya = 1st, na biyu = 2nd)
|
|
44
|
+
// First has special form "na fari" or "farko"
|
|
45
|
+
const ORDINAL_PREFIX = 'na'
|
|
46
|
+
const ORDINAL_FIRST = 'na farko'
|
|
47
|
+
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Currency Vocabulary (Nigerian Naira)
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
const NAIRA = 'naira'
|
|
53
|
+
const KOBO = 'kobo'
|
|
54
|
+
|
|
37
55
|
// ============================================================================
|
|
38
56
|
// Precomputed Lookup Table
|
|
39
57
|
// ============================================================================
|
|
@@ -47,8 +65,8 @@ function buildSegment (n) {
|
|
|
47
65
|
if (n === 0) return ''
|
|
48
66
|
|
|
49
67
|
const ones = n % 10
|
|
50
|
-
const tensDigit = Math.
|
|
51
|
-
const hundredsDigit = Math.
|
|
68
|
+
const tensDigit = Math.trunc(n / 10) % 10
|
|
69
|
+
const hundredsDigit = Math.trunc(n / 100)
|
|
52
70
|
|
|
53
71
|
const parts = []
|
|
54
72
|
|
|
@@ -200,8 +218,8 @@ function decimalPartToWords (decimalPart) {
|
|
|
200
218
|
* @param {number | string | bigint} value - The numeric value to convert
|
|
201
219
|
* @returns {string} The number in Hausa words
|
|
202
220
|
*/
|
|
203
|
-
function
|
|
204
|
-
const { isNegative, integerPart, decimalPart } =
|
|
221
|
+
function toCardinal (value) {
|
|
222
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
205
223
|
|
|
206
224
|
let result = ''
|
|
207
225
|
|
|
@@ -218,8 +236,89 @@ function toWords (value) {
|
|
|
218
236
|
return result
|
|
219
237
|
}
|
|
220
238
|
|
|
239
|
+
// ============================================================================
|
|
240
|
+
// ORDINAL: toOrdinal(value)
|
|
241
|
+
// ============================================================================
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Converts a non-negative integer to Hausa ordinal words.
|
|
245
|
+
*
|
|
246
|
+
* Hausa ordinals: na farko (1st), na biyu (2nd), na uku (3rd), etc.
|
|
247
|
+
*
|
|
248
|
+
* @param {bigint} n - Positive integer to convert
|
|
249
|
+
* @returns {string} Hausa ordinal words
|
|
250
|
+
*/
|
|
251
|
+
function integerToOrdinal (n) {
|
|
252
|
+
// Special form for first
|
|
253
|
+
if (n === 1n) return ORDINAL_FIRST
|
|
254
|
+
|
|
255
|
+
// For 2+, use "na" prefix + cardinal
|
|
256
|
+
return ORDINAL_PREFIX + ' ' + integerToWords(n)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Converts a numeric value to Hausa ordinal words.
|
|
261
|
+
*
|
|
262
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
263
|
+
* @returns {string} The number as ordinal words
|
|
264
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
265
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* toOrdinal(1) // 'na farko'
|
|
269
|
+
* toOrdinal(2) // 'na biyu'
|
|
270
|
+
* toOrdinal(10) // 'na goma'
|
|
271
|
+
*/
|
|
272
|
+
function toOrdinal (value) {
|
|
273
|
+
const integerPart = parseOrdinalValue(value)
|
|
274
|
+
return integerToOrdinal(integerPart)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// ============================================================================
|
|
278
|
+
// CURRENCY: toCurrency(value)
|
|
279
|
+
// ============================================================================
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Converts a numeric value to Hausa currency words (Nigerian Naira).
|
|
283
|
+
*
|
|
284
|
+
* Uses naira and kobo (100 kobo = 1 naira).
|
|
285
|
+
*
|
|
286
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
287
|
+
* @returns {string} The amount in Hausa currency words
|
|
288
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
289
|
+
* @throws {Error} If value is not a valid number format
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* toCurrency(42) // 'arba'in da biyu naira'
|
|
293
|
+
* toCurrency(1.50) // 'ɗaya naira da hamsin kobo'
|
|
294
|
+
* toCurrency(-5) // 'babu biyar naira'
|
|
295
|
+
*/
|
|
296
|
+
function toCurrency (value) {
|
|
297
|
+
const { isNegative, dollars: naira, cents: kobo } = parseCurrencyValue(value)
|
|
298
|
+
|
|
299
|
+
let result = ''
|
|
300
|
+
if (isNegative) {
|
|
301
|
+
result = NEGATIVE + ' '
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Naira part
|
|
305
|
+
if (naira > 0n || kobo === 0n) {
|
|
306
|
+
result += integerToWords(naira) + ' ' + NAIRA
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Kobo part
|
|
310
|
+
if (kobo > 0n) {
|
|
311
|
+
if (naira > 0n) {
|
|
312
|
+
result += ' da '
|
|
313
|
+
}
|
|
314
|
+
result += integerToWords(kobo) + ' ' + KOBO
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return result
|
|
318
|
+
}
|
|
319
|
+
|
|
221
320
|
// ============================================================================
|
|
222
321
|
// Exports
|
|
223
322
|
// ============================================================================
|
|
224
323
|
|
|
225
|
-
export {
|
|
324
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/hbo-IL.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Biblical Hebrew words.
|
|
3
|
+
*
|
|
4
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
5
|
+
* @param {Object} [options] - Optional configuration
|
|
6
|
+
* @param {('masculine'|'feminine')} [options.gender='masculine'] - Grammatical gender
|
|
7
|
+
* @param {string} [options.andWord='ו'] - Custom conjunction word
|
|
8
|
+
* @returns {string} The number in Biblical Hebrew words
|
|
9
|
+
*/
|
|
10
|
+
export function toCardinal(value: number | string | bigint, options?: {
|
|
11
|
+
gender?: "masculine" | "feminine" | undefined;
|
|
12
|
+
andWord?: string | undefined;
|
|
13
|
+
}): string;
|
|
14
|
+
/**
|
|
15
|
+
* Converts a numeric value to Biblical Hebrew ordinal words.
|
|
16
|
+
*
|
|
17
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
18
|
+
* @returns {string} The ordinal in Biblical Hebrew words
|
|
19
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
20
|
+
* @throws {Error} If value is not a positive integer
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* toOrdinal(1) // 'ראשון'
|
|
24
|
+
* toOrdinal(21) // 'עשרים וראשון'
|
|
25
|
+
*/
|
|
26
|
+
export function toOrdinal(value: number | string | bigint): string;
|
|
27
|
+
/**
|
|
28
|
+
* Converts a numeric value to Biblical Hebrew Shekel currency words.
|
|
29
|
+
*
|
|
30
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
31
|
+
* @returns {string} The currency in Biblical Hebrew words
|
|
32
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
33
|
+
* @throws {Error} If value is not a valid number format
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* toCurrency(1) // 'שקל אחד'
|
|
37
|
+
* toCurrency(2.50) // 'שניים שקלים חמישים גרות'
|
|
38
|
+
*/
|
|
39
|
+
export function toCurrency(value: number | string | bigint): string;
|