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
|
-
* Marathi language converter
|
|
2
|
+
* Marathi (India) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: mr-IN | Marathi 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 Marathi 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,94 @@ 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 Marathi ordinal words.
|
|
176
|
+
*
|
|
177
|
+
* Marathi ordinals: First 6 are irregular, then add -वा suffix.
|
|
178
|
+
*
|
|
179
|
+
* @param {bigint} n - Positive integer to convert
|
|
180
|
+
* @returns {string} Marathi 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 Marathi 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(3) // 'तिसरा'
|
|
205
|
+
* toOrdinal(10) // 'दहावा'
|
|
206
|
+
*/
|
|
207
|
+
function toOrdinal (value) {
|
|
208
|
+
const integerPart = parseOrdinalValue(value)
|
|
209
|
+
return integerToOrdinal(integerPart)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ============================================================================
|
|
213
|
+
// CURRENCY: toCurrency(value, options?)
|
|
214
|
+
// ============================================================================
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Converts a numeric value to Marathi currency words (Indian Rupee).
|
|
218
|
+
*
|
|
219
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
220
|
+
* @returns {string} The amount in Marathi currency words
|
|
221
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
222
|
+
* @throws {Error} If value is not a valid number format
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* toCurrency(42.50) // 'बेचाळीस रुपये पन्नास पैसे'
|
|
226
|
+
* toCurrency(1) // 'एक रुपया'
|
|
227
|
+
* toCurrency(0.01) // 'एक पैसा'
|
|
228
|
+
*/
|
|
229
|
+
function toCurrency (value) {
|
|
230
|
+
const { isNegative, dollars: rupees, cents: paise } = parseCurrencyValue(value)
|
|
231
|
+
|
|
232
|
+
// Build result
|
|
233
|
+
let result = ''
|
|
234
|
+
if (isNegative) result = NEGATIVE + ' '
|
|
235
|
+
|
|
236
|
+
// Rupees part - show if non-zero, or if no paise
|
|
237
|
+
if (rupees > 0n || paise === 0n) {
|
|
238
|
+
result += integerToWords(rupees)
|
|
239
|
+
// Singular for 1 rupee, plural otherwise
|
|
240
|
+
result += ' ' + (rupees === 1n ? RUPEE : RUPEES)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Paise part
|
|
244
|
+
if (paise > 0n) {
|
|
245
|
+
if (rupees > 0n) {
|
|
246
|
+
result += ' '
|
|
247
|
+
}
|
|
248
|
+
result += integerToWords(paise)
|
|
249
|
+
// Singular for 1 paisa, plural otherwise
|
|
250
|
+
result += ' ' + (paise === 1n ? PAISA : PAISE)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return result
|
|
254
|
+
}
|
|
255
|
+
|
|
146
256
|
// ============================================================================
|
|
147
257
|
// Exports
|
|
148
258
|
// ============================================================================
|
|
149
259
|
|
|
150
|
-
export {
|
|
260
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/ms-MY.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Malay words.
|
|
3
|
+
*
|
|
4
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
5
|
+
* @returns {string} The number in Malay words
|
|
6
|
+
*/
|
|
7
|
+
export function toCardinal(value: number | string | bigint): string;
|
|
8
|
+
/**
|
|
9
|
+
* Converts a numeric value to Malay 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) // 'pertama'
|
|
18
|
+
* toOrdinal(2) // 'kedua'
|
|
19
|
+
* toOrdinal(10) // 'kesepuluh'
|
|
20
|
+
*/
|
|
21
|
+
export function toOrdinal(value: number | string | bigint): string;
|
|
22
|
+
/**
|
|
23
|
+
* Converts a numeric value to Malay currency words (Ringgit).
|
|
24
|
+
*
|
|
25
|
+
* Malaysian Ringgit uses sen as subunit (100 sen = 1 ringgit).
|
|
26
|
+
*
|
|
27
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
28
|
+
* @returns {string} The amount in Malay 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) // 'empat puluh dua ringgit'
|
|
34
|
+
* toCurrency(1.50) // 'satu ringgit lima puluh sen'
|
|
35
|
+
* toCurrency(-5) // 'minus lima ringgit'
|
|
36
|
+
*/
|
|
37
|
+
export function toCurrency(value: number | string | bigint): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Malay (
|
|
2
|
+
* Malay (Malaysia) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: ms-MY | Malay (Bahasa Melayu) as used in Malaysia
|
|
5
5
|
*
|
|
6
6
|
* Key features:
|
|
7
7
|
* - "Se-" prefix for ALL singular scale units (seratus, seribu, sejuta, sebilion)
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* - Note: "lapan" (8) differs from Indonesian "delapan"
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { parseCardinalValue } from './utils/parse-cardinal.js'
|
|
14
|
+
import { parseCurrencyValue } from './utils/parse-currency.js'
|
|
15
|
+
import { parseOrdinalValue } from './utils/parse-ordinal.js'
|
|
14
16
|
|
|
15
17
|
// ============================================================================
|
|
16
18
|
// Vocabulary
|
|
@@ -28,6 +30,21 @@ const ZERO = 'sifar'
|
|
|
28
30
|
const NEGATIVE = 'minus'
|
|
29
31
|
const DECIMAL_SEP = 'perpuluhan'
|
|
30
32
|
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Ordinal Vocabulary
|
|
35
|
+
// ============================================================================
|
|
36
|
+
|
|
37
|
+
const ORDINAL_PREFIX = 'ke'
|
|
38
|
+
// First is special: "pertama" (not "kesatu")
|
|
39
|
+
const ORDINAL_FIRST = 'pertama'
|
|
40
|
+
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Currency Vocabulary (Malaysian Ringgit)
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
const RINGGIT = 'ringgit'
|
|
46
|
+
const SEN = 'sen'
|
|
47
|
+
|
|
31
48
|
// ============================================================================
|
|
32
49
|
// Segment Building
|
|
33
50
|
// ============================================================================
|
|
@@ -36,8 +53,8 @@ function buildSegment (n) {
|
|
|
36
53
|
if (n === 0) return ''
|
|
37
54
|
|
|
38
55
|
const onesDigit = n % 10
|
|
39
|
-
const tensDigit = Math.
|
|
40
|
-
const hundredsDigit = Math.
|
|
56
|
+
const tensDigit = Math.trunc(n / 10) % 10
|
|
57
|
+
const hundredsDigit = Math.trunc(n / 100)
|
|
41
58
|
|
|
42
59
|
const parts = []
|
|
43
60
|
|
|
@@ -175,8 +192,8 @@ function decimalPartToWords (decimalPart) {
|
|
|
175
192
|
* @param {number | string | bigint} value - The numeric value to convert
|
|
176
193
|
* @returns {string} The number in Malay words
|
|
177
194
|
*/
|
|
178
|
-
function
|
|
179
|
-
const { isNegative, integerPart, decimalPart } =
|
|
195
|
+
function toCardinal (value) {
|
|
196
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
180
197
|
|
|
181
198
|
let result = ''
|
|
182
199
|
|
|
@@ -193,8 +210,94 @@ function toWords (value) {
|
|
|
193
210
|
return result
|
|
194
211
|
}
|
|
195
212
|
|
|
213
|
+
// ============================================================================
|
|
214
|
+
// ORDINAL: toOrdinal(value)
|
|
215
|
+
// ============================================================================
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Converts a non-negative integer to Malay ordinal words.
|
|
219
|
+
*
|
|
220
|
+
* Malay ordinals use "ke-" prefix + cardinal number.
|
|
221
|
+
* Special case: "pertama" for 1st (not "kesatu").
|
|
222
|
+
*
|
|
223
|
+
* @param {bigint} n - Positive integer to convert
|
|
224
|
+
* @returns {string} Malay ordinal words
|
|
225
|
+
*/
|
|
226
|
+
function integerToOrdinal (n) {
|
|
227
|
+
// Special case: 1st is "pertama"
|
|
228
|
+
if (n === 1n) {
|
|
229
|
+
return ORDINAL_FIRST
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// All others: "ke" + cardinal (no hyphen in Malay)
|
|
233
|
+
return ORDINAL_PREFIX + integerToWords(n)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Converts a numeric value to Malay ordinal words.
|
|
238
|
+
*
|
|
239
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
240
|
+
* @returns {string} The number as ordinal words
|
|
241
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
242
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* toOrdinal(1) // 'pertama'
|
|
246
|
+
* toOrdinal(2) // 'kedua'
|
|
247
|
+
* toOrdinal(10) // 'kesepuluh'
|
|
248
|
+
*/
|
|
249
|
+
function toOrdinal (value) {
|
|
250
|
+
const integerPart = parseOrdinalValue(value)
|
|
251
|
+
return integerToOrdinal(integerPart)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ============================================================================
|
|
255
|
+
// CURRENCY: toCurrency(value)
|
|
256
|
+
// ============================================================================
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Converts a numeric value to Malay currency words (Ringgit).
|
|
260
|
+
*
|
|
261
|
+
* Malaysian Ringgit uses sen as subunit (100 sen = 1 ringgit).
|
|
262
|
+
*
|
|
263
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
264
|
+
* @returns {string} The amount in Malay currency words
|
|
265
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
266
|
+
* @throws {Error} If value is not a valid number format
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* toCurrency(42) // 'empat puluh dua ringgit'
|
|
270
|
+
* toCurrency(1.50) // 'satu ringgit lima puluh sen'
|
|
271
|
+
* toCurrency(-5) // 'minus lima ringgit'
|
|
272
|
+
*/
|
|
273
|
+
function toCurrency (value) {
|
|
274
|
+
const { isNegative, dollars: ringgit, cents: sen } = parseCurrencyValue(value)
|
|
275
|
+
|
|
276
|
+
let result = ''
|
|
277
|
+
if (isNegative) {
|
|
278
|
+
result = NEGATIVE + ' '
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Ringgit part - show if non-zero, or if no sen
|
|
282
|
+
if (ringgit > 0n || sen === 0n) {
|
|
283
|
+
result += integerToWords(ringgit)
|
|
284
|
+
result += ' ' + RINGGIT
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Sen part
|
|
288
|
+
if (sen > 0n) {
|
|
289
|
+
if (ringgit > 0n) {
|
|
290
|
+
result += ' '
|
|
291
|
+
}
|
|
292
|
+
result += integerToWords(sen)
|
|
293
|
+
result += ' ' + SEN
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return result
|
|
297
|
+
}
|
|
298
|
+
|
|
196
299
|
// ============================================================================
|
|
197
300
|
// Exports
|
|
198
301
|
// ============================================================================
|
|
199
302
|
|
|
200
|
-
export {
|
|
303
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/nb-NO.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Norwegian Bokmål words.
|
|
3
|
+
*
|
|
4
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
5
|
+
* @returns {string} The number in Norwegian 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(21) // 'tjue-en'
|
|
11
|
+
* toCardinal(101) // 'en hundre og en'
|
|
12
|
+
* toCardinal(1000000) // 'en million'
|
|
13
|
+
*/
|
|
14
|
+
export function toCardinal(value: number | string | bigint): string;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a numeric value to Norwegian Bokmål ordinal words.
|
|
17
|
+
*
|
|
18
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
19
|
+
* @returns {string} The number as ordinal words
|
|
20
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
21
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* toOrdinal(1) // 'første'
|
|
25
|
+
* toOrdinal(2) // 'andre'
|
|
26
|
+
* toOrdinal(21) // 'tjue-ende'
|
|
27
|
+
*/
|
|
28
|
+
export function toOrdinal(value: number | string | bigint): string;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a numeric value to Norwegian currency words (Norwegian Krone).
|
|
31
|
+
*
|
|
32
|
+
* Uses krone/kroner and øre (100 øre = 1 krone).
|
|
33
|
+
*
|
|
34
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
35
|
+
* @returns {string} The amount in Norwegian currency words
|
|
36
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
37
|
+
* @throws {Error} If value is not a valid number format
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* toCurrency(1) // 'en krone'
|
|
41
|
+
* toCurrency(42) // 'førti-to kroner'
|
|
42
|
+
* toCurrency(1.50) // 'en krone og femti øre'
|
|
43
|
+
*/
|
|
44
|
+
export function toCurrency(value: number | string | bigint): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Norwegian Bokmål language converter
|
|
2
|
+
* Norwegian Bokmål (Norway) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: nb-NO | Norwegian Bokmål as used in Norway
|
|
5
5
|
*
|
|
6
6
|
* Key features:
|
|
7
7
|
* - Hyphenated tens+ones: "tjue-en" (21)
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* - Short scale: million, milliard, billion, etc.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { parseCardinalValue } from './utils/parse-cardinal.js'
|
|
14
|
+
import { parseCurrencyValue } from './utils/parse-currency.js'
|
|
15
|
+
import { parseOrdinalValue } from './utils/parse-ordinal.js'
|
|
14
16
|
|
|
15
17
|
// ============================================================================
|
|
16
18
|
// Vocabulary (module-level constants)
|
|
@@ -31,6 +33,34 @@ const DECIMAL_SEP = 'komma'
|
|
|
31
33
|
// Short scale: million, milliard, billion, etc.
|
|
32
34
|
const SCALES = ['million', 'milliard', 'billion', 'billiard', 'kvintillion', 'sekstillion', 'septillion', 'oktillion']
|
|
33
35
|
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Ordinal Vocabulary
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
// Norwegian ordinals: 1st-12th special forms, then cardinal + -de/-te
|
|
41
|
+
const ORDINAL_SPECIAL = {
|
|
42
|
+
1: 'første',
|
|
43
|
+
2: 'andre',
|
|
44
|
+
3: 'tredje',
|
|
45
|
+
4: 'fjerde',
|
|
46
|
+
5: 'femte',
|
|
47
|
+
6: 'sjette',
|
|
48
|
+
7: 'sjuende',
|
|
49
|
+
8: 'åttende',
|
|
50
|
+
9: 'niende',
|
|
51
|
+
10: 'tiende',
|
|
52
|
+
11: 'ellevte',
|
|
53
|
+
12: 'tolvte'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ============================================================================
|
|
57
|
+
// Currency Vocabulary (Norwegian Krone)
|
|
58
|
+
// ============================================================================
|
|
59
|
+
|
|
60
|
+
const KRONE = 'krone'
|
|
61
|
+
const KRONER = 'kroner' // plural
|
|
62
|
+
const ORE = 'øre' // same singular and plural
|
|
63
|
+
|
|
34
64
|
// ============================================================================
|
|
35
65
|
// Segment Building
|
|
36
66
|
// ============================================================================
|
|
@@ -43,8 +73,8 @@ function buildSegment (n) {
|
|
|
43
73
|
if (n === 0) return { word: '', hasHundred: false }
|
|
44
74
|
|
|
45
75
|
const ones = n % 10
|
|
46
|
-
const tens = Math.
|
|
47
|
-
const hundreds = Math.
|
|
76
|
+
const tens = Math.trunc(n / 10) % 10
|
|
77
|
+
const hundreds = Math.trunc(n / 100)
|
|
48
78
|
|
|
49
79
|
const parts = []
|
|
50
80
|
let hasHundred = false
|
|
@@ -256,12 +286,12 @@ function decimalPartToWords (decimalPart) {
|
|
|
256
286
|
* @throws {Error} If value is not a valid number format
|
|
257
287
|
*
|
|
258
288
|
* @example
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
289
|
+
* toCardinal(21) // 'tjue-en'
|
|
290
|
+
* toCardinal(101) // 'en hundre og en'
|
|
291
|
+
* toCardinal(1000000) // 'en million'
|
|
262
292
|
*/
|
|
263
|
-
function
|
|
264
|
-
const { isNegative, integerPart, decimalPart } =
|
|
293
|
+
function toCardinal (value) {
|
|
294
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
265
295
|
|
|
266
296
|
let result = ''
|
|
267
297
|
|
|
@@ -278,8 +308,120 @@ function toWords (value) {
|
|
|
278
308
|
return result
|
|
279
309
|
}
|
|
280
310
|
|
|
311
|
+
// ============================================================================
|
|
312
|
+
// ORDINAL: toOrdinal(value)
|
|
313
|
+
// ============================================================================
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Converts a non-negative integer to Norwegian Bokmål ordinal words.
|
|
317
|
+
*
|
|
318
|
+
* Norwegian ordinals: første (1st), andre (2nd), tredje (3rd), etc.
|
|
319
|
+
* 1-12 have special forms, others use cardinal + de/te suffix.
|
|
320
|
+
* Teens (13-19): drop -en and add -ende (tretten → trettende)
|
|
321
|
+
* Numbers ending in 'en' (one): replace with 'ende' (tjue-en → tjue-ende)
|
|
322
|
+
* Numbers ending in 9 (ni): add 'ede' (nitti-ni → nitti-niede)
|
|
323
|
+
*
|
|
324
|
+
* @param {bigint} n - Positive integer to convert
|
|
325
|
+
* @returns {string} Norwegian ordinal words
|
|
326
|
+
*/
|
|
327
|
+
function integerToOrdinal (n) {
|
|
328
|
+
// Special forms for 1-12
|
|
329
|
+
if (n >= 1n && n <= 12n) {
|
|
330
|
+
return ORDINAL_SPECIAL[Number(n)]
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const num = Number(n)
|
|
334
|
+
const cardinal = integerToWords(n)
|
|
335
|
+
|
|
336
|
+
// Teens 13-19: drop -en and add -ende
|
|
337
|
+
if (num >= 13 && num <= 19) {
|
|
338
|
+
// tretten → trettende, nitten → nittende
|
|
339
|
+
return cardinal.slice(0, -2) + 'ende'
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// For other numbers, check if cardinal ends with 'en' (one)
|
|
343
|
+
// tjue-en → tjue-ende, en hundre og en → en hundre og ende
|
|
344
|
+
if (cardinal.endsWith('en')) {
|
|
345
|
+
return cardinal.slice(0, -2) + 'ende'
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Numbers ending in 'ni' (9): add 'ede'
|
|
349
|
+
// nitti-ni → nitti-niede
|
|
350
|
+
if (cardinal.endsWith('ni')) {
|
|
351
|
+
return cardinal + 'ede'
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Others use -de suffix
|
|
355
|
+
return cardinal + 'de'
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Converts a numeric value to Norwegian Bokmål ordinal words.
|
|
360
|
+
*
|
|
361
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
362
|
+
* @returns {string} The number as ordinal words
|
|
363
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
364
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* toOrdinal(1) // 'første'
|
|
368
|
+
* toOrdinal(2) // 'andre'
|
|
369
|
+
* toOrdinal(21) // 'tjue-ende'
|
|
370
|
+
*/
|
|
371
|
+
function toOrdinal (value) {
|
|
372
|
+
const integerPart = parseOrdinalValue(value)
|
|
373
|
+
return integerToOrdinal(integerPart)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// ============================================================================
|
|
377
|
+
// CURRENCY: toCurrency(value)
|
|
378
|
+
// ============================================================================
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Converts a numeric value to Norwegian currency words (Norwegian Krone).
|
|
382
|
+
*
|
|
383
|
+
* Uses krone/kroner and øre (100 øre = 1 krone).
|
|
384
|
+
*
|
|
385
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
386
|
+
* @returns {string} The amount in Norwegian currency words
|
|
387
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
388
|
+
* @throws {Error} If value is not a valid number format
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* toCurrency(1) // 'en krone'
|
|
392
|
+
* toCurrency(42) // 'førti-to kroner'
|
|
393
|
+
* toCurrency(1.50) // 'en krone og femti øre'
|
|
394
|
+
*/
|
|
395
|
+
function toCurrency (value) {
|
|
396
|
+
const { isNegative, dollars: kroner, cents: ore } = parseCurrencyValue(value)
|
|
397
|
+
|
|
398
|
+
let result = ''
|
|
399
|
+
if (isNegative) {
|
|
400
|
+
result = NEGATIVE + ' '
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// Kroner part
|
|
404
|
+
if (kroner > 0n || ore === 0n) {
|
|
405
|
+
if (kroner === 1n) {
|
|
406
|
+
result += 'en ' + KRONE
|
|
407
|
+
} else {
|
|
408
|
+
result += integerToWords(kroner) + ' ' + KRONER
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Øre part
|
|
413
|
+
if (ore > 0n) {
|
|
414
|
+
if (kroner > 0n) {
|
|
415
|
+
result += ' og '
|
|
416
|
+
}
|
|
417
|
+
result += integerToWords(ore) + ' ' + ORE
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return result
|
|
421
|
+
}
|
|
422
|
+
|
|
281
423
|
// ============================================================================
|
|
282
424
|
// Public API
|
|
283
425
|
// ============================================================================
|
|
284
426
|
|
|
285
|
-
export {
|
|
427
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/nl-NL.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Dutch 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
|
+
* @param {Object} [options] - Optional configuration
|
|
9
|
+
* @param {boolean} [options.accentOne=true] - Use "één" instead of "een"
|
|
10
|
+
* @param {boolean} [options.includeOptionalAnd=false] - Include "en" before small numbers
|
|
11
|
+
* @param {boolean} [options.noHundredPairing=false] - Disable hundred pairing (1104→duizend honderdvier)
|
|
12
|
+
* @returns {string} The number in Dutch words
|
|
13
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
14
|
+
* @throws {Error} If value is not a valid number format
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* toCardinal(21) // 'eenentwintig'
|
|
18
|
+
* toCardinal(1) // 'één'
|
|
19
|
+
* toCardinal(1, {accentOne: false}) // 'een'
|
|
20
|
+
* toCardinal(1104) // 'elfhonderd vier'
|
|
21
|
+
*/
|
|
22
|
+
export function toCardinal(value: number | string | bigint, options?: {
|
|
23
|
+
accentOne?: boolean | undefined;
|
|
24
|
+
includeOptionalAnd?: boolean | undefined;
|
|
25
|
+
noHundredPairing?: boolean | undefined;
|
|
26
|
+
}): string;
|
|
27
|
+
/**
|
|
28
|
+
* Converts a number to Dutch ordinal words.
|
|
29
|
+
*
|
|
30
|
+
* @param {number | string | bigint} value - The number to convert
|
|
31
|
+
* @returns {string} Dutch ordinal words
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* toOrdinal(1) // 'eerste'
|
|
35
|
+
* toOrdinal(21) // 'eenentwintigste'
|
|
36
|
+
* toOrdinal(100) // 'honderdste'
|
|
37
|
+
*/
|
|
38
|
+
export function toOrdinal(value: number | string | bigint): string;
|
|
39
|
+
/**
|
|
40
|
+
* Converts a number to Dutch currency words (Euro).
|
|
41
|
+
*
|
|
42
|
+
* @param {number | string | bigint} value - The amount to convert
|
|
43
|
+
* @param {Object} [options]
|
|
44
|
+
* @param {boolean} [options.and=true] - Include "en" between euros and cents
|
|
45
|
+
* @returns {string} Dutch currency words
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* toCurrency(42.50) // 'tweeënveertig euro en vijftig cent'
|
|
49
|
+
* toCurrency(1) // 'één euro'
|
|
50
|
+
* toCurrency(0.01) // 'één cent'
|
|
51
|
+
*/
|
|
52
|
+
export function toCurrency(value: number | string | bigint, options?: {
|
|
53
|
+
and?: boolean | undefined;
|
|
54
|
+
}): string;
|