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
|
-
* Telugu language converter
|
|
2
|
+
* Telugu (India) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: te-IN | Telugu 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
|
|
@@ -21,6 +23,28 @@ const ZERO = 'సున్నా'
|
|
|
21
23
|
const NEGATIVE = 'మైనస్'
|
|
22
24
|
const DECIMAL_SEP = 'పాయింట్'
|
|
23
25
|
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Ordinal Vocabulary
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
// Ordinal suffix (adds to cardinal for numbers >= 7)
|
|
31
|
+
const ORDINAL_SUFFIX = 'వ'
|
|
32
|
+
|
|
33
|
+
// Special ordinals for first few numbers
|
|
34
|
+
const ORDINAL_SPECIAL = ['', 'మొదటి', 'రెండవ', 'మూడవ', 'నాలుగవ', 'ఐదవ', 'ఆరవ']
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Currency Vocabulary (Indian Rupee)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
// Rupee (singular/plural same in Telugu)
|
|
41
|
+
const RUPEE = 'రూపాయి'
|
|
42
|
+
const RUPEES = 'రూపాయలు'
|
|
43
|
+
|
|
44
|
+
// Paisa (singular/plural same in Telugu)
|
|
45
|
+
const PAISA = 'పైసా'
|
|
46
|
+
const PAISE = 'పైసలు'
|
|
47
|
+
|
|
24
48
|
const BELOW_HUNDRED = [
|
|
25
49
|
'సున్నా', 'ఒకటి', 'రెండు', 'మూడు', 'నాలుగు', 'ఐదు', 'ఆరు', 'ఏడు', 'ఎనిమిది', 'తొమ్మిది',
|
|
26
50
|
'పది', 'పదకొండు', 'పన్నెండు', 'పదమూడు', 'పద్నాలుగు', 'పదిహేను', 'పదహారు', 'పదిహేడు', 'పద్దెనిమిది', 'పంతొమ్మిది',
|
|
@@ -131,8 +155,8 @@ function decimalPartToWords (decimalPart) {
|
|
|
131
155
|
* @param {number | string | bigint} value - The numeric value to convert
|
|
132
156
|
* @returns {string} The number in Telugu words
|
|
133
157
|
*/
|
|
134
|
-
function
|
|
135
|
-
const { isNegative, integerPart, decimalPart } =
|
|
158
|
+
function toCardinal (value) {
|
|
159
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
136
160
|
|
|
137
161
|
let result = ''
|
|
138
162
|
|
|
@@ -149,8 +173,93 @@ function toWords (value) {
|
|
|
149
173
|
return result
|
|
150
174
|
}
|
|
151
175
|
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// ORDINAL: toOrdinal(value)
|
|
178
|
+
// ============================================================================
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Converts a positive integer to Telugu ordinal words.
|
|
182
|
+
*
|
|
183
|
+
* Telugu ordinals: First 6 are irregular, then add -వ suffix.
|
|
184
|
+
*
|
|
185
|
+
* @param {bigint} n - Positive integer to convert
|
|
186
|
+
* @returns {string} Telugu ordinal words
|
|
187
|
+
*/
|
|
188
|
+
function integerToOrdinal (n) {
|
|
189
|
+
// Special ordinals for 1-6
|
|
190
|
+
if (n >= 1n && n <= 6n) {
|
|
191
|
+
return ORDINAL_SPECIAL[Number(n)]
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// For 7 and above, add suffix to cardinal
|
|
195
|
+
const cardinal = integerToWords(n)
|
|
196
|
+
return cardinal + ORDINAL_SUFFIX
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Converts a numeric value to Telugu ordinal words.
|
|
201
|
+
*
|
|
202
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
203
|
+
* @returns {string} The number as ordinal words
|
|
204
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
205
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* toOrdinal(1) // 'మొదటి'
|
|
209
|
+
* toOrdinal(2) // 'రెండవ'
|
|
210
|
+
* toOrdinal(10) // 'పదివ'
|
|
211
|
+
*/
|
|
212
|
+
function toOrdinal (value) {
|
|
213
|
+
const integerPart = parseOrdinalValue(value)
|
|
214
|
+
return integerToOrdinal(integerPart)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ============================================================================
|
|
218
|
+
// CURRENCY: toCurrency(value, options?)
|
|
219
|
+
// ============================================================================
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Converts a numeric value to Telugu currency words (Indian Rupee).
|
|
223
|
+
*
|
|
224
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
225
|
+
* @returns {string} The amount in Telugu currency words
|
|
226
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
227
|
+
* @throws {Error} If value is not a valid number format
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* toCurrency(42.50) // 'నలభై రెండు రూపాయలు యాభై పైసలు'
|
|
231
|
+
* toCurrency(1) // 'ఒకటి రూపాయి'
|
|
232
|
+
* toCurrency(0.01) // 'ఒకటి పైసా'
|
|
233
|
+
*/
|
|
234
|
+
function toCurrency (value) {
|
|
235
|
+
const { isNegative, dollars: rupees, cents: paise } = parseCurrencyValue(value)
|
|
236
|
+
|
|
237
|
+
// Build result
|
|
238
|
+
let result = ''
|
|
239
|
+
if (isNegative) result = NEGATIVE + ' '
|
|
240
|
+
|
|
241
|
+
// Rupees part - show if non-zero, or if no paise
|
|
242
|
+
if (rupees > 0n || paise === 0n) {
|
|
243
|
+
result += integerToWords(rupees)
|
|
244
|
+
// Singular for 1 rupee, plural otherwise
|
|
245
|
+
result += ' ' + (rupees === 1n ? RUPEE : RUPEES)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Paise part
|
|
249
|
+
if (paise > 0n) {
|
|
250
|
+
if (rupees > 0n) {
|
|
251
|
+
result += ' '
|
|
252
|
+
}
|
|
253
|
+
result += integerToWords(paise)
|
|
254
|
+
// Singular for 1 paisa, plural otherwise
|
|
255
|
+
result += ' ' + (paise === 1n ? PAISA : PAISE)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return result
|
|
259
|
+
}
|
|
260
|
+
|
|
152
261
|
// ============================================================================
|
|
153
262
|
// Exports
|
|
154
263
|
// ============================================================================
|
|
155
264
|
|
|
156
|
-
export {
|
|
265
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/th-TH.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Thai words.
|
|
3
|
+
*
|
|
4
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
5
|
+
* @returns {string} The number in Thai words
|
|
6
|
+
*/
|
|
7
|
+
export function toCardinal(value: number | string | bigint): string;
|
|
8
|
+
/**
|
|
9
|
+
* Converts a numeric value to Thai 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 Thai currency words (Baht).
|
|
24
|
+
*
|
|
25
|
+
* Thai Baht uses satang as subunit (100 satang = 1 baht).
|
|
26
|
+
* When whole amounts, adds "ถ้วน" (exactly) suffix.
|
|
27
|
+
*
|
|
28
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
29
|
+
* @returns {string} The amount in Thai currency words
|
|
30
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
31
|
+
* @throws {Error} If value is not a valid number format
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* toCurrency(42) // 'สี่สิบสองบาทถ้วน'
|
|
35
|
+
* toCurrency(1.50) // 'หนึ่งบาทห้าสิบสตางค์'
|
|
36
|
+
* toCurrency(-5) // 'ลบห้าบาทถ้วน'
|
|
37
|
+
*/
|
|
38
|
+
export function toCurrency(value: number | string | bigint): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Thai language converter
|
|
2
|
+
* Thai (Thailand) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: th-TH | Thai as used in Thailand
|
|
5
5
|
*
|
|
6
6
|
* Key features:
|
|
7
7
|
* - No word separators (continuous Thai script)
|
|
@@ -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
|
|
@@ -23,6 +25,20 @@ const ZERO = 'ศูนย์'
|
|
|
23
25
|
const NEGATIVE = 'ลบ'
|
|
24
26
|
const DECIMAL_SEP = 'จุด'
|
|
25
27
|
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Ordinal Vocabulary
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
const ORDINAL_PREFIX = 'ที่'
|
|
33
|
+
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Currency Vocabulary (Thai Baht)
|
|
36
|
+
// ============================================================================
|
|
37
|
+
|
|
38
|
+
const BAHT = 'บาท'
|
|
39
|
+
const SATANG = 'สตางค์'
|
|
40
|
+
const BAHT_ONLY = 'ถ้วน' // "exactly" suffix when no satang
|
|
41
|
+
|
|
26
42
|
// ============================================================================
|
|
27
43
|
// Conversion Functions
|
|
28
44
|
// ============================================================================
|
|
@@ -136,8 +152,8 @@ function decimalPartToWords (decimalPart) {
|
|
|
136
152
|
* @param {number | string | bigint} value - The numeric value to convert
|
|
137
153
|
* @returns {string} The number in Thai words
|
|
138
154
|
*/
|
|
139
|
-
function
|
|
140
|
-
const { isNegative, integerPart, decimalPart } =
|
|
155
|
+
function toCardinal (value) {
|
|
156
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
141
157
|
|
|
142
158
|
let result = ''
|
|
143
159
|
|
|
@@ -154,8 +170,85 @@ function toWords (value) {
|
|
|
154
170
|
return result
|
|
155
171
|
}
|
|
156
172
|
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// ORDINAL: toOrdinal(value)
|
|
175
|
+
// ============================================================================
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Converts a non-negative integer to Thai ordinal words.
|
|
179
|
+
*
|
|
180
|
+
* Thai ordinals use "ที่" prefix + cardinal number.
|
|
181
|
+
*
|
|
182
|
+
* @param {bigint} n - Positive integer to convert
|
|
183
|
+
* @returns {string} Thai ordinal words
|
|
184
|
+
*/
|
|
185
|
+
function integerToOrdinal (n) {
|
|
186
|
+
return ORDINAL_PREFIX + integerToWords(n)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Converts a numeric value to Thai ordinal words.
|
|
191
|
+
*
|
|
192
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
193
|
+
* @returns {string} The number as ordinal words
|
|
194
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
195
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* toOrdinal(1) // 'ที่หนึ่ง'
|
|
199
|
+
* toOrdinal(2) // 'ที่สอง'
|
|
200
|
+
* toOrdinal(10) // 'ที่สิบ'
|
|
201
|
+
*/
|
|
202
|
+
function toOrdinal (value) {
|
|
203
|
+
const integerPart = parseOrdinalValue(value)
|
|
204
|
+
return integerToOrdinal(integerPart)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ============================================================================
|
|
208
|
+
// CURRENCY: toCurrency(value)
|
|
209
|
+
// ============================================================================
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Converts a numeric value to Thai currency words (Baht).
|
|
213
|
+
*
|
|
214
|
+
* Thai Baht uses satang as subunit (100 satang = 1 baht).
|
|
215
|
+
* When whole amounts, adds "ถ้วน" (exactly) suffix.
|
|
216
|
+
*
|
|
217
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
218
|
+
* @returns {string} The amount in Thai currency words
|
|
219
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
220
|
+
* @throws {Error} If value is not a valid number format
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* toCurrency(42) // 'สี่สิบสองบาทถ้วน'
|
|
224
|
+
* toCurrency(1.50) // 'หนึ่งบาทห้าสิบสตางค์'
|
|
225
|
+
* toCurrency(-5) // 'ลบห้าบาทถ้วน'
|
|
226
|
+
*/
|
|
227
|
+
function toCurrency (value) {
|
|
228
|
+
const { isNegative, dollars: baht, cents: satang } = parseCurrencyValue(value)
|
|
229
|
+
|
|
230
|
+
let result = ''
|
|
231
|
+
if (isNegative) {
|
|
232
|
+
result = NEGATIVE
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Baht part - always show
|
|
236
|
+
result += integerToWords(baht)
|
|
237
|
+
result += BAHT
|
|
238
|
+
|
|
239
|
+
// Satang part or "exactly" suffix
|
|
240
|
+
if (satang > 0n) {
|
|
241
|
+
result += integerToWords(satang)
|
|
242
|
+
result += SATANG
|
|
243
|
+
} else {
|
|
244
|
+
result += BAHT_ONLY
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return result
|
|
248
|
+
}
|
|
249
|
+
|
|
157
250
|
// ============================================================================
|
|
158
251
|
// Exports
|
|
159
252
|
// ============================================================================
|
|
160
253
|
|
|
161
|
-
export {
|
|
254
|
+
export { toCardinal, toOrdinal, toCurrency }
|
package/src/tr-TR.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a numeric value to Turkish words.
|
|
3
|
+
*
|
|
4
|
+
* @param {number | string | bigint} value - The numeric value to convert
|
|
5
|
+
* @param {Object} [options] - Conversion options
|
|
6
|
+
* @param {boolean} [options.dropSpaces=false] - Remove spaces for compound form
|
|
7
|
+
* @returns {string} The number in Turkish words
|
|
8
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
9
|
+
* @throws {Error} If value is not a valid number format
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* toCardinal(21) // 'yirmi bir'
|
|
13
|
+
* toCardinal(21, { dropSpaces: true }) // 'yirmibir'
|
|
14
|
+
* toCardinal(1000) // 'bin'
|
|
15
|
+
*/
|
|
16
|
+
export function toCardinal(value: number | string | bigint, options?: {
|
|
17
|
+
dropSpaces?: boolean | undefined;
|
|
18
|
+
}): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a numeric value to Turkish ordinal words.
|
|
21
|
+
*
|
|
22
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
23
|
+
* @returns {string} The number as ordinal words
|
|
24
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
25
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* toOrdinal(1) // 'birinci'
|
|
29
|
+
* toOrdinal(2) // 'ikinci'
|
|
30
|
+
* toOrdinal(21) // 'yirmibirinci'
|
|
31
|
+
*/
|
|
32
|
+
export function toOrdinal(value: number | string | bigint): string;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a numeric value to Turkish currency words (Turkish Lira).
|
|
35
|
+
*
|
|
36
|
+
* Uses lira and kuruş (100 kuruş = 1 lira).
|
|
37
|
+
*
|
|
38
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
39
|
+
* @returns {string} The amount in Turkish currency words
|
|
40
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
41
|
+
* @throws {Error} If value is not a valid number format
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* toCurrency(42) // 'kırk iki lira'
|
|
45
|
+
* toCurrency(1.50) // 'bir lira elli kuruş'
|
|
46
|
+
* toCurrency(-5) // 'eksi beş lira'
|
|
47
|
+
*/
|
|
48
|
+
export function toCurrency(value: number | string | bigint): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Turkish language converter
|
|
2
|
+
* Turkish (Turkey) language converter
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* CLDR: tr-TR | Turkish as used in Turkey
|
|
5
5
|
*
|
|
6
6
|
* Key features:
|
|
7
7
|
* - Omits 'bir' (one) before hundreds and thousands
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* - Short scale naming
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { parseCardinalValue } from './utils/parse-cardinal.js'
|
|
13
|
+
import { parseCurrencyValue } from './utils/parse-currency.js'
|
|
14
|
+
import { parseOrdinalValue } from './utils/parse-ordinal.js'
|
|
15
|
+
import { validateOptions } from './utils/validate-options.js'
|
|
14
16
|
|
|
15
17
|
// ============================================================================
|
|
16
18
|
// Vocabulary (module-level constants)
|
|
@@ -31,6 +33,32 @@ const DECIMAL_SEP = 'virgül'
|
|
|
31
33
|
// Short scale
|
|
32
34
|
const SCALES = ['milyon', 'milyar', 'trilyon', 'katrilyon', 'kentilyon']
|
|
33
35
|
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Ordinal Vocabulary
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
// Turkish ordinals use -(i/ı/u/ü)nci/ncı/ncu/ncü suffix with vowel harmony
|
|
41
|
+
// Special forms for 1-10
|
|
42
|
+
const ORDINAL_SPECIAL = {
|
|
43
|
+
1: 'birinci',
|
|
44
|
+
2: 'ikinci',
|
|
45
|
+
3: 'üçüncü',
|
|
46
|
+
4: 'dördüncü',
|
|
47
|
+
5: 'beşinci',
|
|
48
|
+
6: 'altıncı',
|
|
49
|
+
7: 'yedinci',
|
|
50
|
+
8: 'sekizinci',
|
|
51
|
+
9: 'dokuzuncu',
|
|
52
|
+
10: 'onuncu'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Currency Vocabulary (Turkish Lira)
|
|
57
|
+
// ============================================================================
|
|
58
|
+
|
|
59
|
+
const LIRA = 'lira' // same singular and plural
|
|
60
|
+
const KURUS = 'kuruş' // subunit (100 kuruş = 1 lira)
|
|
61
|
+
|
|
34
62
|
// ============================================================================
|
|
35
63
|
// Segment Building
|
|
36
64
|
// ============================================================================
|
|
@@ -43,8 +71,8 @@ function buildSegment (n, separator = ' ') {
|
|
|
43
71
|
if (n === 0) return ''
|
|
44
72
|
|
|
45
73
|
const ones = n % 10
|
|
46
|
-
const tens = Math.
|
|
47
|
-
const hundreds = Math.
|
|
74
|
+
const tens = Math.trunc(n / 10) % 10
|
|
75
|
+
const hundreds = Math.trunc(n / 100)
|
|
48
76
|
|
|
49
77
|
const parts = []
|
|
50
78
|
|
|
@@ -86,10 +114,10 @@ function buildSegment (n, separator = ' ') {
|
|
|
86
114
|
* @param {Object} options - Conversion options
|
|
87
115
|
* @returns {string} Turkish words
|
|
88
116
|
*/
|
|
89
|
-
function integerToWords (n,
|
|
117
|
+
function integerToWords (n, dropSpaces) {
|
|
90
118
|
if (n === 0n) return ZERO
|
|
91
119
|
|
|
92
|
-
const sep =
|
|
120
|
+
const sep = dropSpaces ? '' : ' '
|
|
93
121
|
|
|
94
122
|
// Fast path: numbers < 1000
|
|
95
123
|
if (n < 1000n) {
|
|
@@ -117,7 +145,7 @@ function integerToWords (n, options = {}) {
|
|
|
117
145
|
}
|
|
118
146
|
|
|
119
147
|
// For numbers >= 1,000,000, use scale decomposition
|
|
120
|
-
return buildLargeNumberWords(n,
|
|
148
|
+
return buildLargeNumberWords(n, dropSpaces)
|
|
121
149
|
}
|
|
122
150
|
|
|
123
151
|
/**
|
|
@@ -127,8 +155,8 @@ function integerToWords (n, options = {}) {
|
|
|
127
155
|
* @param {Object} options - Conversion options
|
|
128
156
|
* @returns {string} Turkish words
|
|
129
157
|
*/
|
|
130
|
-
function buildLargeNumberWords (n,
|
|
131
|
-
const sep =
|
|
158
|
+
function buildLargeNumberWords (n, dropSpaces) {
|
|
159
|
+
const sep = dropSpaces ? '' : ' '
|
|
132
160
|
|
|
133
161
|
const numStr = n.toString()
|
|
134
162
|
const len = numStr.length
|
|
@@ -188,8 +216,8 @@ function buildLargeNumberWords (n, options) {
|
|
|
188
216
|
* @param {Object} options - Conversion options
|
|
189
217
|
* @returns {string} Turkish words for decimal part
|
|
190
218
|
*/
|
|
191
|
-
function decimalPartToWords (decimalPart,
|
|
192
|
-
const sep =
|
|
219
|
+
function decimalPartToWords (decimalPart, dropSpaces) {
|
|
220
|
+
const sep = dropSpaces ? '' : ' '
|
|
193
221
|
let result = ''
|
|
194
222
|
|
|
195
223
|
// Handle leading zeros
|
|
@@ -204,7 +232,7 @@ function decimalPartToWords (decimalPart, options) {
|
|
|
204
232
|
const remainder = decimalPart.slice(i)
|
|
205
233
|
if (remainder) {
|
|
206
234
|
if (result) result += sep
|
|
207
|
-
result += integerToWords(BigInt(remainder),
|
|
235
|
+
result += integerToWords(BigInt(remainder), dropSpaces)
|
|
208
236
|
}
|
|
209
237
|
|
|
210
238
|
return result
|
|
@@ -221,25 +249,142 @@ function decimalPartToWords (decimalPart, options) {
|
|
|
221
249
|
* @throws {Error} If value is not a valid number format
|
|
222
250
|
*
|
|
223
251
|
* @example
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
252
|
+
* toCardinal(21) // 'yirmi bir'
|
|
253
|
+
* toCardinal(21, { dropSpaces: true }) // 'yirmibir'
|
|
254
|
+
* toCardinal(1000) // 'bin'
|
|
227
255
|
*/
|
|
228
|
-
function
|
|
256
|
+
function toCardinal (value, options) {
|
|
229
257
|
options = validateOptions(options)
|
|
230
|
-
const { isNegative, integerPart, decimalPart } =
|
|
258
|
+
const { isNegative, integerPart, decimalPart } = parseCardinalValue(value)
|
|
259
|
+
|
|
260
|
+
// Apply option defaults
|
|
261
|
+
const { dropSpaces = false } = options
|
|
231
262
|
|
|
232
|
-
const sep =
|
|
263
|
+
const sep = dropSpaces ? '' : ' '
|
|
233
264
|
let result = ''
|
|
234
265
|
|
|
235
266
|
if (isNegative) {
|
|
236
267
|
result = NEGATIVE + sep
|
|
237
268
|
}
|
|
238
269
|
|
|
239
|
-
result += integerToWords(integerPart,
|
|
270
|
+
result += integerToWords(integerPart, dropSpaces)
|
|
240
271
|
|
|
241
272
|
if (decimalPart) {
|
|
242
|
-
result += sep + DECIMAL_SEP + sep + decimalPartToWords(decimalPart,
|
|
273
|
+
result += sep + DECIMAL_SEP + sep + decimalPartToWords(decimalPart, dropSpaces)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return result
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ============================================================================
|
|
280
|
+
// ORDINAL: toOrdinal(value)
|
|
281
|
+
// ============================================================================
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Determines the ordinal suffix based on Turkish vowel harmony.
|
|
285
|
+
* @param {string} word - The cardinal word
|
|
286
|
+
* @returns {string} The appropriate suffix
|
|
287
|
+
*/
|
|
288
|
+
function getOrdinalSuffix (word) {
|
|
289
|
+
// Turkish vowel harmony: back vowels (a,ı,o,u) vs front vowels (e,i,ö,ü)
|
|
290
|
+
// Find last vowel to determine suffix
|
|
291
|
+
const backVowels = 'aıou'
|
|
292
|
+
const frontVowels = 'eiöü'
|
|
293
|
+
|
|
294
|
+
// Scan from end for last vowel
|
|
295
|
+
for (let i = word.length - 1; i >= 0; i--) {
|
|
296
|
+
const char = word[i]
|
|
297
|
+
if (backVowels.includes(char)) {
|
|
298
|
+
// Back vowels: -ıncı (after ı,a) or -uncu (after o,u)
|
|
299
|
+
if ('ou'.includes(char)) return 'uncu'
|
|
300
|
+
return 'ıncı'
|
|
301
|
+
}
|
|
302
|
+
if (frontVowels.includes(char)) {
|
|
303
|
+
// Front vowels: -inci (after e,i) or -üncü (after ö,ü)
|
|
304
|
+
if ('öü'.includes(char)) return 'üncü'
|
|
305
|
+
return 'inci'
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return 'inci' // default
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Converts a non-negative integer to Turkish ordinal words.
|
|
313
|
+
*
|
|
314
|
+
* Turkish ordinals: birinci (1st), ikinci (2nd), üçüncü (3rd), etc.
|
|
315
|
+
* Uses vowel harmony for suffix selection.
|
|
316
|
+
*
|
|
317
|
+
* @param {bigint} n - Positive integer to convert
|
|
318
|
+
* @returns {string} Turkish ordinal words
|
|
319
|
+
*/
|
|
320
|
+
function integerToOrdinal (n) {
|
|
321
|
+
// Special forms for 1-10
|
|
322
|
+
if (n >= 1n && n <= 10n) {
|
|
323
|
+
return ORDINAL_SPECIAL[Number(n)]
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// For numbers > 10, add appropriate suffix to cardinal (dropSpaces=true)
|
|
327
|
+
const cardinal = integerToWords(n, true)
|
|
328
|
+
const suffix = getOrdinalSuffix(cardinal)
|
|
329
|
+
return cardinal + suffix
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Converts a numeric value to Turkish ordinal words.
|
|
334
|
+
*
|
|
335
|
+
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
|
|
336
|
+
* @returns {string} The number as ordinal words
|
|
337
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
338
|
+
* @throws {RangeError} If value is negative, zero, or has a decimal part
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* toOrdinal(1) // 'birinci'
|
|
342
|
+
* toOrdinal(2) // 'ikinci'
|
|
343
|
+
* toOrdinal(21) // 'yirmibirinci'
|
|
344
|
+
*/
|
|
345
|
+
function toOrdinal (value) {
|
|
346
|
+
const integerPart = parseOrdinalValue(value)
|
|
347
|
+
return integerToOrdinal(integerPart)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ============================================================================
|
|
351
|
+
// CURRENCY: toCurrency(value)
|
|
352
|
+
// ============================================================================
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Converts a numeric value to Turkish currency words (Turkish Lira).
|
|
356
|
+
*
|
|
357
|
+
* Uses lira and kuruş (100 kuruş = 1 lira).
|
|
358
|
+
*
|
|
359
|
+
* @param {number | string | bigint} value - The currency amount to convert
|
|
360
|
+
* @returns {string} The amount in Turkish currency words
|
|
361
|
+
* @throws {TypeError} If value is not a valid numeric type
|
|
362
|
+
* @throws {Error} If value is not a valid number format
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* toCurrency(42) // 'kırk iki lira'
|
|
366
|
+
* toCurrency(1.50) // 'bir lira elli kuruş'
|
|
367
|
+
* toCurrency(-5) // 'eksi beş lira'
|
|
368
|
+
*/
|
|
369
|
+
function toCurrency (value) {
|
|
370
|
+
const { isNegative, dollars: lira, cents: kurus } = parseCurrencyValue(value)
|
|
371
|
+
|
|
372
|
+
let result = ''
|
|
373
|
+
if (isNegative) {
|
|
374
|
+
result = NEGATIVE + ' '
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Lira part
|
|
378
|
+
if (lira > 0n || kurus === 0n) {
|
|
379
|
+
result += integerToWords(lira, false) + ' ' + LIRA
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Kuruş part
|
|
383
|
+
if (kurus > 0n) {
|
|
384
|
+
if (lira > 0n) {
|
|
385
|
+
result += ' '
|
|
386
|
+
}
|
|
387
|
+
result += integerToWords(kurus, false) + ' ' + KURUS
|
|
243
388
|
}
|
|
244
389
|
|
|
245
390
|
return result
|
|
@@ -249,4 +394,4 @@ function toWords (value, options) {
|
|
|
249
394
|
// Public API
|
|
250
395
|
// ============================================================================
|
|
251
396
|
|
|
252
|
-
export {
|
|
397
|
+
export { toCardinal, toOrdinal, toCurrency }
|