n2words 5.0.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/CHANGELOG.md +133 -40
  2. package/README.md +6 -4
  3. package/dist/am-ET.js +2 -2
  4. package/dist/am-ET.umd.js +2 -2
  5. package/dist/am-Latn-ET.js +2 -2
  6. package/dist/am-Latn-ET.umd.js +2 -2
  7. package/dist/ar-SA.js +2 -2
  8. package/dist/ar-SA.umd.js +2 -2
  9. package/dist/az-AZ.js +2 -2
  10. package/dist/az-AZ.umd.js +2 -2
  11. package/dist/bn-BD.js +2 -2
  12. package/dist/bn-BD.umd.js +2 -2
  13. package/dist/cs-CZ.js +2 -2
  14. package/dist/cs-CZ.umd.js +2 -2
  15. package/dist/da-DK.js +2 -2
  16. package/dist/da-DK.umd.js +2 -2
  17. package/dist/de-DE.js +2 -2
  18. package/dist/de-DE.umd.js +2 -2
  19. package/dist/el-GR.js +2 -2
  20. package/dist/el-GR.umd.js +2 -2
  21. package/dist/en-AU.js +2 -2
  22. package/dist/en-AU.umd.js +2 -2
  23. package/dist/en-BD.js +2 -2
  24. package/dist/en-BD.umd.js +2 -2
  25. package/dist/en-CA.js +2 -2
  26. package/dist/en-CA.umd.js +2 -2
  27. package/dist/en-GB.js +2 -2
  28. package/dist/en-GB.umd.js +2 -2
  29. package/dist/en-GH.js +2 -2
  30. package/dist/en-GH.umd.js +2 -2
  31. package/dist/en-IE.js +2 -2
  32. package/dist/en-IE.umd.js +2 -2
  33. package/dist/en-IN.js +2 -2
  34. package/dist/en-IN.umd.js +2 -2
  35. package/dist/en-KE.js +2 -2
  36. package/dist/en-KE.umd.js +2 -2
  37. package/dist/en-MY.js +2 -2
  38. package/dist/en-MY.umd.js +2 -2
  39. package/dist/en-NG.js +2 -2
  40. package/dist/en-NG.umd.js +2 -2
  41. package/dist/en-NZ.js +2 -2
  42. package/dist/en-NZ.umd.js +2 -2
  43. package/dist/en-PH.js +2 -2
  44. package/dist/en-PH.umd.js +2 -2
  45. package/dist/en-PK.js +2 -2
  46. package/dist/en-PK.umd.js +2 -2
  47. package/dist/en-SG.js +2 -2
  48. package/dist/en-SG.umd.js +2 -2
  49. package/dist/en-US.js +2 -2
  50. package/dist/en-US.umd.js +2 -2
  51. package/dist/en-ZA.js +2 -2
  52. package/dist/en-ZA.umd.js +2 -2
  53. package/dist/es-ES.js +2 -2
  54. package/dist/es-ES.umd.js +2 -2
  55. package/dist/es-MX.js +2 -2
  56. package/dist/es-MX.umd.js +2 -2
  57. package/dist/es-US.js +2 -2
  58. package/dist/es-US.umd.js +2 -2
  59. package/dist/fa-IR.js +2 -2
  60. package/dist/fa-IR.umd.js +2 -2
  61. package/dist/fi-FI.js +2 -2
  62. package/dist/fi-FI.umd.js +2 -2
  63. package/dist/fil-PH.js +2 -2
  64. package/dist/fil-PH.umd.js +2 -2
  65. package/dist/fr-BE.js +2 -2
  66. package/dist/fr-BE.umd.js +2 -2
  67. package/dist/fr-FR.js +2 -2
  68. package/dist/fr-FR.umd.js +2 -2
  69. package/dist/gu-IN.js +2 -2
  70. package/dist/gu-IN.umd.js +2 -2
  71. package/dist/ha-NG.js +2 -2
  72. package/dist/ha-NG.umd.js +2 -2
  73. package/dist/hbo-IL.js +2 -2
  74. package/dist/hbo-IL.umd.js +2 -2
  75. package/dist/he-IL.js +2 -2
  76. package/dist/he-IL.umd.js +2 -2
  77. package/dist/hi-IN.js +2 -2
  78. package/dist/hi-IN.umd.js +2 -2
  79. package/dist/hr-HR.js +2 -2
  80. package/dist/hr-HR.umd.js +2 -2
  81. package/dist/hu-HU.js +2 -2
  82. package/dist/hu-HU.umd.js +2 -2
  83. package/dist/id-ID.js +2 -2
  84. package/dist/id-ID.umd.js +2 -2
  85. package/dist/it-IT.js +2 -2
  86. package/dist/it-IT.umd.js +2 -2
  87. package/dist/ja-JP.js +2 -2
  88. package/dist/ja-JP.umd.js +2 -2
  89. package/dist/ka-GE.js +2 -2
  90. package/dist/ka-GE.umd.js +2 -2
  91. package/dist/kn-IN.js +2 -2
  92. package/dist/kn-IN.umd.js +2 -2
  93. package/dist/ko-KR.js +2 -2
  94. package/dist/ko-KR.umd.js +2 -2
  95. package/dist/lt-LT.js +2 -2
  96. package/dist/lt-LT.umd.js +2 -2
  97. package/dist/lv-LV.js +2 -2
  98. package/dist/lv-LV.umd.js +2 -2
  99. package/dist/mr-IN.js +2 -2
  100. package/dist/mr-IN.umd.js +2 -2
  101. package/dist/ms-MY.js +2 -2
  102. package/dist/ms-MY.umd.js +2 -2
  103. package/dist/nb-NO.js +2 -2
  104. package/dist/nb-NO.umd.js +2 -2
  105. package/dist/nl-NL.js +2 -2
  106. package/dist/nl-NL.umd.js +2 -2
  107. package/dist/pa-IN.js +2 -2
  108. package/dist/pa-IN.umd.js +2 -2
  109. package/dist/pl-PL.js +2 -2
  110. package/dist/pl-PL.umd.js +2 -2
  111. package/dist/pt-BR.js +2 -2
  112. package/dist/pt-BR.umd.js +2 -2
  113. package/dist/pt-PT.js +2 -2
  114. package/dist/pt-PT.umd.js +2 -2
  115. package/dist/ro-RO.js +2 -2
  116. package/dist/ro-RO.umd.js +2 -2
  117. package/dist/ru-RU.js +2 -2
  118. package/dist/ru-RU.umd.js +2 -2
  119. package/dist/sr-Cyrl-RS.js +2 -2
  120. package/dist/sr-Cyrl-RS.umd.js +2 -2
  121. package/dist/sr-Latn-RS.js +2 -2
  122. package/dist/sr-Latn-RS.umd.js +2 -2
  123. package/dist/sv-SE.js +2 -2
  124. package/dist/sv-SE.umd.js +2 -2
  125. package/dist/sw-KE.js +2 -2
  126. package/dist/sw-KE.umd.js +2 -2
  127. package/dist/ta-IN.js +2 -2
  128. package/dist/ta-IN.umd.js +2 -2
  129. package/dist/te-IN.js +2 -2
  130. package/dist/te-IN.umd.js +2 -2
  131. package/dist/th-TH.js +2 -2
  132. package/dist/th-TH.umd.js +2 -2
  133. package/dist/tr-TR.js +2 -2
  134. package/dist/tr-TR.umd.js +2 -2
  135. package/dist/uk-UA.js +2 -2
  136. package/dist/uk-UA.umd.js +2 -2
  137. package/dist/ur-PK.js +2 -2
  138. package/dist/ur-PK.umd.js +2 -2
  139. package/dist/vi-VN.js +2 -2
  140. package/dist/vi-VN.umd.js +2 -2
  141. package/dist/yo-NG.js +2 -2
  142. package/dist/yo-NG.umd.js +2 -2
  143. package/dist/zh-Hans-CN.js +2 -2
  144. package/dist/zh-Hans-CN.umd.js +2 -2
  145. package/dist/zh-Hant-TW.js +2 -2
  146. package/dist/zh-Hant-TW.umd.js +2 -2
  147. package/package.json +33 -24
  148. package/src/am-ET.d.ts +3 -5
  149. package/src/am-ET.js +41 -16
  150. package/src/am-Latn-ET.d.ts +3 -5
  151. package/src/am-Latn-ET.js +45 -16
  152. package/src/ar-SA.d.ts +44 -18
  153. package/src/ar-SA.js +93 -40
  154. package/src/az-AZ.d.ts +3 -5
  155. package/src/az-AZ.js +58 -20
  156. package/src/bn-BD.d.ts +3 -5
  157. package/src/bn-BD.js +32 -16
  158. package/src/cs-CZ.d.ts +3 -6
  159. package/src/cs-CZ.js +66 -42
  160. package/src/da-DK.d.ts +3 -6
  161. package/src/da-DK.js +53 -48
  162. package/src/de-DE.d.ts +17 -11
  163. package/src/de-DE.js +88 -57
  164. package/src/el-GR.d.ts +3 -6
  165. package/src/el-GR.js +45 -32
  166. package/src/en-AU.d.ts +17 -11
  167. package/src/en-AU.js +56 -41
  168. package/src/en-BD.d.ts +17 -11
  169. package/src/en-BD.js +60 -41
  170. package/src/en-CA.d.ts +36 -18
  171. package/src/en-CA.js +67 -46
  172. package/src/en-GB.d.ts +17 -11
  173. package/src/en-GB.js +56 -41
  174. package/src/en-GH.d.ts +32 -3
  175. package/src/en-GH.js +104 -26
  176. package/src/en-IE.d.ts +17 -11
  177. package/src/en-IE.js +56 -41
  178. package/src/en-IN.d.ts +17 -11
  179. package/src/en-IN.js +60 -41
  180. package/src/en-KE.d.ts +28 -3
  181. package/src/en-KE.js +93 -26
  182. package/src/en-MY.d.ts +26 -3
  183. package/src/en-MY.js +91 -26
  184. package/src/en-NG.d.ts +17 -11
  185. package/src/en-NG.js +56 -41
  186. package/src/en-NZ.d.ts +32 -3
  187. package/src/en-NZ.js +85 -31
  188. package/src/en-PH.d.ts +32 -3
  189. package/src/en-PH.js +97 -26
  190. package/src/en-PK.d.ts +17 -11
  191. package/src/en-PK.js +60 -41
  192. package/src/en-SG.d.ts +28 -3
  193. package/src/en-SG.js +93 -26
  194. package/src/en-US.d.ts +36 -18
  195. package/src/en-US.js +70 -47
  196. package/src/en-ZA.d.ts +17 -11
  197. package/src/en-ZA.js +56 -41
  198. package/src/es-ES.d.ts +53 -21
  199. package/src/es-ES.js +104 -56
  200. package/src/es-MX.d.ts +53 -21
  201. package/src/es-MX.js +104 -56
  202. package/src/es-US.d.ts +53 -21
  203. package/src/es-US.js +92 -51
  204. package/src/fa-IR.d.ts +3 -5
  205. package/src/fa-IR.js +28 -13
  206. package/src/fi-FI.d.ts +3 -6
  207. package/src/fi-FI.js +47 -29
  208. package/src/fil-PH.d.ts +3 -5
  209. package/src/fil-PH.js +61 -28
  210. package/src/fr-BE.d.ts +31 -15
  211. package/src/fr-BE.js +128 -57
  212. package/src/fr-FR.d.ts +31 -16
  213. package/src/fr-FR.js +97 -60
  214. package/src/gu-IN.d.ts +3 -5
  215. package/src/gu-IN.js +31 -16
  216. package/src/ha-NG.d.ts +3 -5
  217. package/src/ha-NG.js +55 -27
  218. package/src/hbo-IL.d.ts +26 -12
  219. package/src/hbo-IL.js +92 -51
  220. package/src/he-IL.d.ts +17 -10
  221. package/src/he-IL.js +92 -50
  222. package/src/hi-IN.d.ts +3 -5
  223. package/src/hi-IN.js +30 -17
  224. package/src/hr-HR.d.ts +21 -10
  225. package/src/hr-HR.js +89 -33
  226. package/src/hu-HU.d.ts +3 -5
  227. package/src/hu-HU.js +57 -23
  228. package/src/id-ID.d.ts +3 -5
  229. package/src/id-ID.js +56 -23
  230. package/src/it-IT.d.ts +17 -11
  231. package/src/it-IT.js +74 -43
  232. package/src/ja-JP.d.ts +3 -6
  233. package/src/ja-JP.js +39 -26
  234. package/src/ka-GE.d.ts +3 -6
  235. package/src/ka-GE.js +38 -26
  236. package/src/kn-IN.d.ts +3 -5
  237. package/src/kn-IN.js +31 -16
  238. package/src/ko-KR.d.ts +3 -6
  239. package/src/ko-KR.js +34 -26
  240. package/src/lt-LT.d.ts +21 -11
  241. package/src/lt-LT.js +64 -42
  242. package/src/lv-LV.d.ts +21 -11
  243. package/src/lv-LV.js +79 -51
  244. package/src/mr-IN.d.ts +3 -5
  245. package/src/mr-IN.js +31 -16
  246. package/src/ms-MY.d.ts +3 -5
  247. package/src/ms-MY.js +58 -24
  248. package/src/nb-NO.d.ts +3 -6
  249. package/src/nb-NO.js +54 -34
  250. package/src/nl-NL.d.ts +41 -20
  251. package/src/nl-NL.js +111 -69
  252. package/src/pa-IN.d.ts +3 -5
  253. package/src/pa-IN.js +32 -16
  254. package/src/pl-PL.d.ts +21 -11
  255. package/src/pl-PL.js +69 -45
  256. package/src/pt-BR.d.ts +22 -11
  257. package/src/pt-BR.js +93 -53
  258. package/src/pt-PT.d.ts +17 -11
  259. package/src/pt-PT.js +80 -48
  260. package/src/ro-RO.d.ts +21 -11
  261. package/src/ro-RO.js +77 -39
  262. package/src/ru-RU.d.ts +35 -15
  263. package/src/ru-RU.js +100 -38
  264. package/src/sr-Cyrl-RS.d.ts +35 -15
  265. package/src/sr-Cyrl-RS.js +106 -43
  266. package/src/sr-Latn-RS.d.ts +35 -15
  267. package/src/sr-Latn-RS.js +106 -43
  268. package/src/sv-SE.d.ts +3 -6
  269. package/src/sv-SE.js +53 -34
  270. package/src/sw-KE.d.ts +3 -5
  271. package/src/sw-KE.js +50 -20
  272. package/src/ta-IN.d.ts +3 -5
  273. package/src/ta-IN.js +29 -17
  274. package/src/te-IN.d.ts +3 -5
  275. package/src/te-IN.js +31 -16
  276. package/src/th-TH.d.ts +3 -5
  277. package/src/th-TH.js +42 -19
  278. package/src/tr-TR.d.ts +17 -11
  279. package/src/tr-TR.js +63 -37
  280. package/src/uk-UA.d.ts +21 -10
  281. package/src/uk-UA.js +89 -33
  282. package/src/ur-PK.d.ts +3 -5
  283. package/src/ur-PK.js +32 -16
  284. package/src/utils/check-max.d.ts +26 -0
  285. package/src/utils/check-max.js +33 -0
  286. package/src/utils/expand-scientific.d.ts +0 -4
  287. package/src/utils/expand-scientific.js +7 -9
  288. package/src/utils/is-plain-object.d.ts +3 -4
  289. package/src/utils/is-plain-object.js +3 -4
  290. package/src/utils/parse-cardinal.d.ts +1 -2
  291. package/src/utils/parse-cardinal.js +12 -9
  292. package/src/utils/parse-currency.d.ts +1 -2
  293. package/src/utils/parse-currency.js +9 -11
  294. package/src/utils/parse-ordinal.d.ts +0 -1
  295. package/src/utils/parse-ordinal.js +9 -10
  296. package/src/utils/resolve-options.d.ts +17 -0
  297. package/src/utils/resolve-options.js +56 -0
  298. package/src/utils/scale.d.ts +49 -0
  299. package/src/utils/scale.js +65 -0
  300. package/src/vi-VN.d.ts +3 -6
  301. package/src/vi-VN.js +41 -28
  302. package/src/yo-NG.d.ts +3 -5
  303. package/src/yo-NG.js +49 -33
  304. package/src/zh-Hans-CN.d.ts +45 -20
  305. package/src/zh-Hans-CN.js +84 -31
  306. package/src/zh-Hant-TW.d.ts +45 -20
  307. package/src/zh-Hant-TW.js +85 -34
  308. package/src/utils/validate-options.d.ts +0 -8
  309. package/src/utils/validate-options.js +0 -16
package/dist/en-US.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/en-US v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const r=parseInt(t,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),u=(-1===o?n.length:o)+r;return u>=s.length?i+s+"0".repeat(u-s.length):u<=0?i+"0."+"0".repeat(-u)+s:i+s.slice(0,u)+"."+s.slice(u)}function t(e){const t=e.toString();return r(t)?n(t):t}function r(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const r=e.slice(0,t)||"0",i=e.slice(t+1);return{isNegative:n,integerPart:BigInt(r),decimalPart:i}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);r(t)&&(t=n(t));const i="-"===t[0];i&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:i,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",u=(t.slice(o+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(s),cents:BigInt(u)}}function s(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}const u=["","one","two","three","four","five","six","seven","eight","nine"],l=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],c=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],f=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion"],a="hundred",d="zero",g="minus",h=["","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth"],w=["tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],b=["","","twentieth","thirtieth","fortieth","fiftieth","sixtieth","seventieth","eightieth","ninetieth"],m={word:"",hasHundred:!1};function v(e,n){if(0===e)return m.word="",m.hasHundred=!1,m;const t=e%10,r=Math.trunc(e/10)%10,i=Math.trunc(e/100);let o="";return 1===r?o=l[t]:r>=2?o=t>0?c[r]+"-"+u[t]:c[r]:t>0&&(o=u[t]),i>0?(m.word=o?u[i]+" "+a+(n?" and ":" ")+o:u[i]+" "+a,m.hasHundred=!0):(m.word=o,m.hasHundred=!1),m}function p(e,n,t){if(0n===e)return d;if(e<1000n)return v(Number(e),t).word;if(n&&e>=1100n&&e<=9999n){const n=Number(e),r=Math.trunc(n/100),i=n%100,{word:o}=v(r,t);let s=o+" "+a;if(i>0){const{word:e}=v(i,t);t&&(s+=" and"),s+=" "+e}return s}if(e<1000000n){const n=Number(e/1000n),r=Number(e%1000n),{word:i}=v(n,t);let o=i+" "+f[0];if(r>0){const{word:e,hasHundred:n}=v(r,t);t&&!n&&(o+=" and"),o+=" "+e}return o}return function(e,n){const t=[];let r=e;for(;r>0n;)t.push(Number(r%1000n)),r/=1000n;let i=-1;if(n)for(let e=0;e<t.length;e++)if(0!==t[e]){i=e;break}let o="",s=!1;for(let e=t.length-1;e>=0;e--){const r=t[e];if(0===r)continue;const{word:u,hasHundred:l}=v(r,n);n&&o&&e===i&&s&&!l&&(o+=" and"),o&&(o+=" "),o+=u,e>0?(o+=" "+f[e-1],s=!0):s=!1}return o}(e,t)}function N(e){const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=w[n]:t>=2?i=n>0?c[t]+"-"+h[n]:b[t]:n>0&&(i=h[n]),r>0?i?u[r]+" "+a+" "+i:u[r]+" hundredth":i}const y={enUS:function(e){return function(e){if(e<1000n)return N(Number(e));if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);if(0===t)return v(n,!1).word+" "+f[0]+"th";const{word:r}=v(n,!1);return r+" "+f[0]+" "+N(t)}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=0;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="";for(let e=n.length-1;e>=0;e--){const t=n[e];0!==t&&(i&&(i+=" "),e===r?i+=0===e?N(t):v(t,!1).word+" "+f[e-1]+"th":(i+=v(t,!1).word,e>0&&(i+=" "+f[e-1])))}return i}(e)}(function(e){const t=typeof e;if("bigint"===t){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"===t){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"===t)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(r(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const r=BigInt(e);if(r<=0n)throw new RangeError("Ordinals must be positive integers");return r}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`)}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e))}};e.currency={enUS:function(e,n){n=s(n);const{isNegative:r,dollars:i,cents:u}=function(e){const n=typeof e;if("bigint"===n)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===n){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"===n)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e),{and:l=!0}=n;let c="";return r&&(c=g+" "),(i>0n||0n===u)&&(c+=p(i,!1,!1),c+=" "+(1n===i?"dollar":"dollars")),u>0n&&(i>0n&&(c+=l?" and ":" "),c+=p(u,!1,!1),c+=" "+(1n===u?"cent":"cents")),c}},e.enUS=function(e,o){o=s(o);const{isNegative:u,integerPart:l,decimalPart:c}=function(e){const o=typeof e;if("bigint"===o)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===o){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:i(t(e))}if("string"===o)return i(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return r(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e),{hundredPairing:f=!1,and:a=!1}=o;let h="";return u&&(h=g+" "),h+=p(l,f,a),c&&(h+=" point "+function(e,n){let t="",r=0;for(;r<e.length&&"0"===e[r];)t&&(t+=" "),t+=d,r++;const i=e.slice(r);return i&&(t&&(t+=" "),t+=p(BigInt(i),!1,n)),t}(c,a)),h},e.ordinal=y},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/en-US v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const r=parseInt(t,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),u=(-1===o?n.length:o)+r;return u>=s.length?i+s+"0".repeat(u-s.length):u<=0?i+"0."+"0".repeat(-u)+s:i+s.slice(0,u)+"."+s.slice(u)}function t(e){const t=e.toString();return r(t)?n(t):t}function r(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const r=e.slice(0,t)||"0",i=e.slice(t+1);return{isNegative:n,integerPart:BigInt(r),decimalPart:i}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);r(t)&&(t=n(t));const i="-"===t[0];i&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:i,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",u=(t.slice(o+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(s),cents:BigInt(u)}}function s(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const r=n.toString().length-1,i=n===10n**BigInt(r)?`10^${r} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${i}`)}function u(e){return 10n**BigInt(3*(e+1))}function l(e,n,t){const r={...n};if(void 0===e)return r;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const i=Object.keys(n);for(const[t,o]of Object.entries(e)){if(!Object.hasOwn(n,t))throw new TypeError(`Unknown option "${t}" — expected one of: ${i.join(", ")}`);if(void 0!==o){if(typeof o!=typeof r[t])throw new TypeError(`Option "${t}" must be a ${typeof r[t]}, got ${typeof o}`);r[t]=o}}return r}const f=["","one","two","three","four","five","six","seven","eight","nine"],c=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],a=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],d=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion"],g=u(d.length),h=u(d.length),w=u(d.length),b="hundred",p="zero",m="minus",v=["","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth"],y=["tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],N=["","","twentieth","thirtieth","fortieth","fiftieth","sixtieth","seventieth","eightieth","ninetieth"],I={word:"",hasHundred:!1};function E(e,n){if(0===e)return I.word="",I.hasHundred=!1,I;const t=e%10,r=Math.trunc(e/10)%10,i=Math.trunc(e/100);let o="";return 1===r?o=c[t]:r>=2?o=t>0?a[r]+"-"+f[t]:a[r]:t>0&&(o=f[t]),i>0?(I.word=o?f[i]+" "+b+(n?" and ":" ")+o:f[i]+" "+b,I.hasHundred=!0):(I.word=o,I.hasHundred=!1),I}function O(e,n,t){if(0n===e)return p;if(e<1000n)return E(Number(e),t).word;if(n&&e>=1100n&&e<=9999n){const n=Number(e),r=Math.trunc(n/100),i=n%100,{word:o}=E(r,t);let s=o+" "+b;if(i>0){const{word:e}=E(i,t);t&&(s+=" and"),s+=" "+e}return s}if(e<1000000n){const n=Number(e/1000n),r=Number(e%1000n),{word:i}=E(n,t);let o=i+" "+d[0];if(r>0){const{word:e,hasHundred:n}=E(r,t);t&&!n&&(o+=" and"),o+=" "+e}return o}return function(e,n){const t=[];let r=e;for(;r>0n;)t.push(Number(r%1000n)),r/=1000n;let i=-1;if(n)for(let e=0;e<t.length;e++)if(0!==t[e]){i=e;break}let o="",s=!1;for(let e=t.length-1;e>=0;e--){const r=t[e];if(0===r)continue;const{word:u,hasHundred:l}=E(r,n);n&&o&&e===i&&s&&!l&&(o+=" and"),o&&(o+=" "),o+=u,e>0?(o+=" "+d[e-1],s=!0):s=!1}return o}(e,t)}const x={hundredPairing:!1,and:!1};function R(e){const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=y[n]:t>=2?i=n>0?a[t]+"-"+v[n]:N[t]:n>0&&(i=v[n]),r>0?i?f[r]+" "+b+" "+i:f[r]+" hundredth":i}const B={and:!0},$={enUS:function(e){const t=function(e){const t=typeof e;if("bigint"==typeof e){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"==typeof e)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(r(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const r=BigInt(e);if(r<=0n)throw new RangeError("Ordinals must be positive integers");return r}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`,{cause:n})}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);return s(t,h),function(e){if(e<1000n)return R(Number(e));if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);if(0===t)return E(n,!1).word+" "+d[0]+"th";const{word:r}=E(n,!1);return r+" "+d[0]+" "+R(t)}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=0;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="";for(let e=n.length-1;e>=0;e--){const t=n[e];0!==t&&(i&&(i+=" "),e===r?i+=0===e?R(t):E(t,!1).word+" "+d[e-1]+"th":(i+=E(t,!1).word,e>0&&(i+=" "+d[e-1])))}return i}(e)}(t)}};e.currency={enUS:function(e,n){const{isNegative:r,dollars:i,cents:u}=function(e){const n=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"==typeof e)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e);s(i,w);const{and:f}=l(n,B);let c="";return r&&(c=m+" "),(i>0n||0n===u)&&(c+=O(i,!1,!1),c+=" "+(1n===i?"dollar":"dollars")),u>0n&&(i>0n&&(c+=f?" and ":" "),c+=O(u,!1,!1),c+=" "+(1n===u?"cent":"cents")),c}},e.enUS=function(e,o){const{isNegative:u,integerPart:f,decimalPart:c}=function(e){const o=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:i(t(e))}if("string"==typeof e)return i(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return r(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e);s(f,g,c);const{hundredPairing:a,and:d}=l(o,x);let h="";return u&&(h=m+" "),h+=O(f,a,d),c&&(h+=" point "+function(e,n){let t="",r=0;for(;r<e.length&&"0"===e[r];)t&&(t+=" "),t+=p,r++;const i=e.slice(r);return i&&(t&&(t+=" "),t+=O(BigInt(i),!1,n)),t}(c,d)),h},e.ordinal=$},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
package/dist/en-ZA.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/en-ZA v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- function e(e){let[n,t]=e.toLowerCase().split("e");const r=parseInt(t,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),u=(-1===o?n.length:o)+r;return u>=s.length?i+s+"0".repeat(u-s.length):u<=0?i+"0."+"0".repeat(-u)+s:i+s.slice(0,u)+"."+s.slice(u)}function n(n){const r=n.toString();return t(r)?e(r):r}function t(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const r=e.slice(0,t)||"0",i=e.slice(t+1);return{isNegative:n,integerPart:BigInt(r),decimalPart:i}}function i(n){let r=n.trim();if(0===r.length||Number.isNaN(Number(r)))throw new RangeError(`Invalid currency format: "${n}"`);t(r)&&(r=e(r));const i="-"===r[0];i&&(r=r.slice(1));const o=r.indexOf(".");if(-1===o)return{isNegative:i,dollars:BigInt(r),cents:0n};const s=r.slice(0,o)||"0",u=(r.slice(o+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(s),cents:BigInt(u)}}const o=["","one","two","three","four","five","six","seven","eight","nine"],s=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],u=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],l=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion"],c="hundred",a="zero",f="minus",d=["","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth"],g=["tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],h=["","","twentieth","thirtieth","fortieth","fiftieth","sixtieth","seventieth","eightieth","ninetieth"],w={word:"",hasHundred:!1};function b(e){if(0===e)return w.word="",w.hasHundred=!1,w;const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=s[n]:t>=2?i=n>0?u[t]+"-"+o[n]:u[t]:n>0&&(i=o[n]),r>0?(w.word=i?o[r]+" "+c+" and "+i:o[r]+" "+c,w.hasHundred=!0):(w.word=i,w.hasHundred=!1),w}function m(e){if(0n===e)return a;if(e<1000n)return b(Number(e)).word;if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n),{word:r}=b(n);let i=r+" "+l[0];if(t>0){const{word:e,hasHundred:n}=b(t);i+=n?" "+e:" and "+e}return i}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=-1;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="",o=!1;for(let e=n.length-1;e>=0;e--){const t=n[e];if(0===t)continue;const{word:s,hasHundred:u}=b(t);i&&e===r&&o&&!u&&(i+=" and"),i&&(i+=" "),i+=s,e>0?(i+=" "+l[e-1],o=!0):o=!1}return i}(e)}function v(i){const{isNegative:o,integerPart:s,decimalPart:u}=function(i){const o=typeof i;if("bigint"===o)return i<0n?{isNegative:!0,integerPart:-i}:{isNegative:!1,integerPart:i};if("number"===o){if(!Number.isFinite(i))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(i)?i<0?{isNegative:!0,integerPart:BigInt(-i)}:{isNegative:!1,integerPart:BigInt(i)}:r(n(i))}if("string"===o)return r(function(n){const r=n.trim();if(0===r.length||Number.isNaN(Number(r)))throw new RangeError(`Invalid number format: "${n}"`);return t(r)?e(r):r}(i));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(i);let l="";return o&&(l=f+" "),l+=m(s),u&&(l+=" point "+function(e){let n="",t=0;for(;t<e.length&&"0"===e[t];)n&&(n+=" "),n+=a,t++;const r=e.slice(t);return r&&(n&&(n+=" "),n+=m(BigInt(r))),n}(u)),l}function N(e){const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=g[n]:t>=2?i=n>0?u[t]+"-"+d[n]:h[t]:n>0&&(i=d[n]),r>0?i?o[r]+" "+c+" "+i:o[r]+" hundredth":i}function p(n){return function(e){if(e<1000n)return N(Number(e));if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);if(0===t)return b(n).word+" "+l[0]+"th";const{word:r}=b(n);return r+" "+l[0]+" "+N(t)}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=0;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="";for(let e=n.length-1;e>=0;e--){const t=n[e];0!==t&&(i&&(i+=" "),e===r?i+=0===e?N(t):b(t).word+" "+l[e-1]+"th":(i+=b(t).word,e>0&&(i+=" "+l[e-1])))}return i}(e)}(function(n){const r=typeof n;if("bigint"===r){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"===r){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"===r)return function(n){const r=n.trim();if(0===r.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===r[0])throw new RangeError("Ordinals cannot be negative");if(r.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(r)){const n=e(r);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(r);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`)}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(n))}function y(e,t){t=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(t);const{isNegative:r,dollars:o,cents:s}=function(e){const t=typeof e;if("bigint"===t)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===t){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:i(n(e))}if("string"===t)return i(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e),{and:u=!0}=t;let l="";return r&&(l=f+" "),(o>0n||0n===s)&&(l+=m(o),l+=" rand"),s>0n&&(o>0n&&(l+=u?" and ":" "),l+=m(s),l+=" "+(1n===s?"cent":"cents")),l}export{v as toCardinal,y as toCurrency,p as toOrdinal};
1
+ /*! n2words/en-ZA v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ function e(e){let[n,t]=e.toLowerCase().split("e");const r=parseInt(t,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),u=(-1===o?n.length:o)+r;return u>=s.length?i+s+"0".repeat(u-s.length):u<=0?i+"0."+"0".repeat(-u)+s:i+s.slice(0,u)+"."+s.slice(u)}function n(n){const r=n.toString();return t(r)?e(r):r}function t(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const r=e.slice(0,t)||"0",i=e.slice(t+1);return{isNegative:n,integerPart:BigInt(r),decimalPart:i}}function i(n){let r=n.trim();if(0===r.length||Number.isNaN(Number(r)))throw new RangeError(`Invalid currency format: "${n}"`);t(r)&&(r=e(r));const i="-"===r[0];i&&(r=r.slice(1));const o=r.indexOf(".");if(-1===o)return{isNegative:i,dollars:BigInt(r),cents:0n};const s=r.slice(0,o)||"0",u=(r.slice(o+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(s),cents:BigInt(u)}}function o(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const r=n.toString().length-1,i=n===10n**BigInt(r)?`10^${r} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${i}`)}function s(e){return 10n**BigInt(3*(e+1))}const u=["","one","two","three","four","five","six","seven","eight","nine"],l=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],c=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],f=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion"],a=s(f.length),g=s(f.length),d=s(f.length),h="hundred",w="zero",b="minus",p=["","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth"],m=["tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],v=["","","twentieth","thirtieth","fortieth","fiftieth","sixtieth","seventieth","eightieth","ninetieth"],y={word:"",hasHundred:!1};function N(e){if(0===e)return y.word="",y.hasHundred=!1,y;const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=l[n]:t>=2?i=n>0?c[t]+"-"+u[n]:c[t]:n>0&&(i=u[n]),r>0?(y.word=i?u[r]+" "+h+" and "+i:u[r]+" "+h,y.hasHundred=!0):(y.word=i,y.hasHundred=!1),y}function I(e){if(0n===e)return w;if(e<1000n)return N(Number(e)).word;if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n),{word:r}=N(n);let i=r+" "+f[0];if(t>0){const{word:e,hasHundred:n}=N(t);i+=n?" "+e:" and "+e}return i}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=-1;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="",o=!1;for(let e=n.length-1;e>=0;e--){const t=n[e];if(0===t)continue;const{word:s,hasHundred:u}=N(t);i&&e===r&&o&&!u&&(i+=" and"),i&&(i+=" "),i+=s,e>0?(i+=" "+f[e-1],o=!0):o=!1}return i}(e)}function E(i){const{isNegative:s,integerPart:u,decimalPart:l}=function(i){const o=typeof i;if("bigint"==typeof i)return i<0n?{isNegative:!0,integerPart:-i}:{isNegative:!1,integerPart:i};if("number"==typeof i){if(!Number.isFinite(i))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(i)?i<0?{isNegative:!0,integerPart:BigInt(-i)}:{isNegative:!1,integerPart:BigInt(i)}:r(n(i))}if("string"==typeof i)return r(function(n){const r=n.trim();if(0===r.length||Number.isNaN(Number(r)))throw new RangeError(`Invalid number format: "${n}"`);return t(r)?e(r):r}(i));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(i);o(u,a,l);let c="";return s&&(c=b+" "),c+=I(u),l&&(c+=" point "+function(e){let n="",t=0;for(;t<e.length&&"0"===e[t];)n&&(n+=" "),n+=w,t++;const r=e.slice(t);return r&&(n&&(n+=" "),n+=I(BigInt(r))),n}(l)),c}function O(e){const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=m[n]:t>=2?i=n>0?c[t]+"-"+p[n]:v[t]:n>0&&(i=p[n]),r>0?i?u[r]+" "+h+" "+i:u[r]+" hundredth":i}function x(n){const r=function(n){const r=typeof n;if("bigint"==typeof n){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"==typeof n){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"==typeof n)return function(n){const r=n.trim();if(0===r.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===r[0])throw new RangeError("Ordinals cannot be negative");if(r.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(r)){const n=e(r);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(r);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`,{cause:e})}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(n);return o(r,g),function(e){if(e<1000n)return O(Number(e));if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);if(0===t)return N(n).word+" "+f[0]+"th";const{word:r}=N(n);return r+" "+f[0]+" "+O(t)}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=0;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="";for(let e=n.length-1;e>=0;e--){const t=n[e];0!==t&&(i&&(i+=" "),e===r?i+=0===e?O(t):N(t).word+" "+f[e-1]+"th":(i+=N(t).word,e>0&&(i+=" "+f[e-1])))}return i}(e)}(r)}const R={and:!0};function B(e,t){const{isNegative:r,dollars:s,cents:u}=function(e){const t=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:i(n(e))}if("string"==typeof e)return i(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);o(s,d);const{and:l}=function(e,n){const t={...n};if(void 0===e)return t;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[i,o]of Object.entries(e)){if(!Object.hasOwn(n,i))throw new TypeError(`Unknown option "${i}" — expected one of: ${r.join(", ")}`);if(void 0!==o){if(typeof o!=typeof t[i])throw new TypeError(`Option "${i}" must be a ${typeof t[i]}, got ${typeof o}`);t[i]=o}}return t}(t,R);let c="";return r&&(c=b+" "),(s>0n||0n===u)&&(c+=I(s),c+=" rand"),u>0n&&(s>0n&&(c+=l?" and ":" "),c+=I(u),c+=" "+(1n===u?"cent":"cents")),c}export{a as cardinalMax,R as currencyDefaults,d as currencyMax,g as ordinalMax,E as toCardinal,B as toCurrency,x as toOrdinal};
package/dist/en-ZA.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/en-ZA v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const r=parseInt(t,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),u=(-1===o?n.length:o)+r;return u>=s.length?i+s+"0".repeat(u-s.length):u<=0?i+"0."+"0".repeat(-u)+s:i+s.slice(0,u)+"."+s.slice(u)}function t(e){const t=e.toString();return r(t)?n(t):t}function r(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const r=e.slice(0,t)||"0",i=e.slice(t+1);return{isNegative:n,integerPart:BigInt(r),decimalPart:i}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);r(t)&&(t=n(t));const i="-"===t[0];i&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:i,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",u=(t.slice(o+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(s),cents:BigInt(u)}}const s=["","one","two","three","four","five","six","seven","eight","nine"],u=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],l=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],c=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion"],f="hundred",a="zero",d="minus",g=["","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth"],h=["tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],w=["","","twentieth","thirtieth","fortieth","fiftieth","sixtieth","seventieth","eightieth","ninetieth"],b={word:"",hasHundred:!1};function m(e){if(0===e)return b.word="",b.hasHundred=!1,b;const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=u[n]:t>=2?i=n>0?l[t]+"-"+s[n]:l[t]:n>0&&(i=s[n]),r>0?(b.word=i?s[r]+" "+f+" and "+i:s[r]+" "+f,b.hasHundred=!0):(b.word=i,b.hasHundred=!1),b}function v(e){if(0n===e)return a;if(e<1000n)return m(Number(e)).word;if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n),{word:r}=m(n);let i=r+" "+c[0];if(t>0){const{word:e,hasHundred:n}=m(t);i+=n?" "+e:" and "+e}return i}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=-1;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="",o=!1;for(let e=n.length-1;e>=0;e--){const t=n[e];if(0===t)continue;const{word:s,hasHundred:u}=m(t);i&&e===r&&o&&!u&&(i+=" and"),i&&(i+=" "),i+=s,e>0?(i+=" "+c[e-1],o=!0):o=!1}return i}(e)}function p(e){const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=h[n]:t>=2?i=n>0?l[t]+"-"+g[n]:w[t]:n>0&&(i=g[n]),r>0?i?s[r]+" "+f+" "+i:s[r]+" hundredth":i}const N={enZA:function(e){return function(e){if(e<1000n)return p(Number(e));if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);if(0===t)return m(n).word+" "+c[0]+"th";const{word:r}=m(n);return r+" "+c[0]+" "+p(t)}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=0;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="";for(let e=n.length-1;e>=0;e--){const t=n[e];0!==t&&(i&&(i+=" "),e===r?i+=0===e?p(t):m(t).word+" "+c[e-1]+"th":(i+=m(t).word,e>0&&(i+=" "+c[e-1])))}return i}(e)}(function(e){const t=typeof e;if("bigint"===t){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"===t){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"===t)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(r(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const r=BigInt(e);if(r<=0n)throw new RangeError("Ordinals must be positive integers");return r}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`)}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e))}};e.currency={enZA:function(e,n){n=function(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}(n);const{isNegative:r,dollars:i,cents:s}=function(e){const n=typeof e;if("bigint"===n)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===n){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"===n)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e),{and:u=!0}=n;let l="";return r&&(l=d+" "),(i>0n||0n===s)&&(l+=v(i),l+=" rand"),s>0n&&(i>0n&&(l+=u?" and ":" "),l+=v(s),l+=" "+(1n===s?"cent":"cents")),l}},e.enZA=function(e){const{isNegative:o,integerPart:s,decimalPart:u}=function(e){const o=typeof e;if("bigint"===o)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===o){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:i(t(e))}if("string"===o)return i(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return r(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e);let l="";return o&&(l=d+" "),l+=v(s),u&&(l+=" point "+function(e){let n="",t=0;for(;t<e.length&&"0"===e[t];)n&&(n+=" "),n+=a,t++;const r=e.slice(t);return r&&(n&&(n+=" "),n+=v(BigInt(r))),n}(u)),l},e.ordinal=N},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/en-ZA v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const r=parseInt(t,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),u=(-1===o?n.length:o)+r;return u>=s.length?i+s+"0".repeat(u-s.length):u<=0?i+"0."+"0".repeat(-u)+s:i+s.slice(0,u)+"."+s.slice(u)}function t(e){const t=e.toString();return r(t)?n(t):t}function r(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const r=e.slice(0,t)||"0",i=e.slice(t+1);return{isNegative:n,integerPart:BigInt(r),decimalPart:i}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);r(t)&&(t=n(t));const i="-"===t[0];i&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:i,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",u=(t.slice(o+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(s),cents:BigInt(u)}}function s(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const r=n.toString().length-1,i=n===10n**BigInt(r)?`10^${r} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${i}`)}function u(e){return 10n**BigInt(3*(e+1))}const l=["","one","two","three","four","five","six","seven","eight","nine"],f=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],c=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],a=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","quindecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion"],d=u(a.length),g=u(a.length),h=u(a.length),w="hundred",b="zero",p="minus",m=["","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth"],v=["tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],y=["","","twentieth","thirtieth","fortieth","fiftieth","sixtieth","seventieth","eightieth","ninetieth"],N={word:"",hasHundred:!1};function I(e){if(0===e)return N.word="",N.hasHundred=!1,N;const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=f[n]:t>=2?i=n>0?c[t]+"-"+l[n]:c[t]:n>0&&(i=l[n]),r>0?(N.word=i?l[r]+" "+w+" and "+i:l[r]+" "+w,N.hasHundred=!0):(N.word=i,N.hasHundred=!1),N}function E(e){if(0n===e)return b;if(e<1000n)return I(Number(e)).word;if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n),{word:r}=I(n);let i=r+" "+a[0];if(t>0){const{word:e,hasHundred:n}=I(t);i+=n?" "+e:" and "+e}return i}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=-1;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="",o=!1;for(let e=n.length-1;e>=0;e--){const t=n[e];if(0===t)continue;const{word:s,hasHundred:u}=I(t);i&&e===r&&o&&!u&&(i+=" and"),i&&(i+=" "),i+=s,e>0?(i+=" "+a[e-1],o=!0):o=!1}return i}(e)}function O(e){const n=e%10,t=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===t?i=v[n]:t>=2?i=n>0?c[t]+"-"+m[n]:y[t]:n>0&&(i=m[n]),r>0?i?l[r]+" "+w+" "+i:l[r]+" hundredth":i}const x={and:!0},R={enZA:function(e){const t=function(e){const t=typeof e;if("bigint"==typeof e){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"==typeof e)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(r(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const r=BigInt(e);if(r<=0n)throw new RangeError("Ordinals must be positive integers");return r}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`,{cause:n})}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);return s(t,g),function(e){if(e<1000n)return O(Number(e));if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);if(0===t)return I(n).word+" "+a[0]+"th";const{word:r}=I(n);return r+" "+a[0]+" "+O(t)}return function(e){const n=[];let t=e;for(;t>0n;)n.push(Number(t%1000n)),t/=1000n;let r=0;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}let i="";for(let e=n.length-1;e>=0;e--){const t=n[e];0!==t&&(i&&(i+=" "),e===r?i+=0===e?O(t):I(t).word+" "+a[e-1]+"th":(i+=I(t).word,e>0&&(i+=" "+a[e-1])))}return i}(e)}(t)}};e.currency={enZA:function(e,n){const{isNegative:r,dollars:i,cents:u}=function(e){const n=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"==typeof e)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e);s(i,h);const{and:l}=function(e,n){const t={...n};if(void 0===e)return t;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[i,o]of Object.entries(e)){if(!Object.hasOwn(n,i))throw new TypeError(`Unknown option "${i}" — expected one of: ${r.join(", ")}`);if(void 0!==o){if(typeof o!=typeof t[i])throw new TypeError(`Option "${i}" must be a ${typeof t[i]}, got ${typeof o}`);t[i]=o}}return t}(n,x);let f="";return r&&(f=p+" "),(i>0n||0n===u)&&(f+=E(i),f+=" rand"),u>0n&&(i>0n&&(f+=l?" and ":" "),f+=E(u),f+=" "+(1n===u?"cent":"cents")),f}},e.enZA=function(e){const{isNegative:o,integerPart:u,decimalPart:l}=function(e){const o=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:i(t(e))}if("string"==typeof e)return i(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return r(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e);s(u,d,l);let f="";return o&&(f=p+" "),f+=E(u),l&&(f+=" point "+function(e){let n="",t=0;for(;t<e.length&&"0"===e[t];)n&&(n+=" "),n+=b,t++;const r=e.slice(t);return r&&(n&&(n+=" "),n+=E(BigInt(r))),n}(l)),f},e.ordinal=R},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
package/dist/es-ES.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/es-ES v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- function e(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function n(n){const i=n.toString();return t(i)?e(i):i}function t(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function r(n){let i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid currency format: "${n}"`);t(i)&&(i=e(i));const r="-"===i[0];r&&(i=i.slice(1));const o=i.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(i),cents:0n};const s=i.slice(0,o)||"0",c=(i.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function o(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}const s=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],c=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],u=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],a=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],l=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],g=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],m=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],f=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],d=["millón","billón","trillón","cuatrillón"],v=["millones","billones","trillones","cuatrillones"],b="mil",h="cero",p="menos",w=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],N=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],I=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],E=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function y(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,d=[];return r>0&&d.push((n?f:m)[r]),0===o||d.push(o<10?(n?c:s)[o]:o<20?u[t]:o<30?(n?l:a)[t]:0===t?g[i]:g[i]+" y "+(n?c:s)[t]),d.join(" ")}function O(e,n){if(1===e)return b;if(e%2==0){const t=e/2-1,i=d[t];return i?n>1n?v[t]:i:""}{const n=v[(e-1)/2-1];return n?b+" "+n:b}}function R(e,n){if(0n===e)return h;if(e<1000n)return y(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=b;else{const e=y(t,!1);r="uno"===e||"una"===e?b:e+" "+b}return i>0&&(r+=" "+y(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?O(e,i):"";r&&(r+=" "),r+=0===e?y(Number(i),n):1===e?1n===i?b:y(Number(i),!1)+" "+o:e%2==1?1n===i?o:y(Number(i),!1)+" "+o:1n===i?"un "+o:y(Number(i),!1)+" "+o}return r}(e,n)}function x(r,s){s=o(s);const{isNegative:c,integerPart:u,decimalPart:a}=function(r){const o=typeof r;if("bigint"===o)return r<0n?{isNegative:!0,integerPart:-r}:{isNegative:!1,integerPart:r};if("number"===o){if(!Number.isFinite(r))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(r)?r<0?{isNegative:!0,integerPart:BigInt(-r)}:{isNegative:!1,integerPart:BigInt(r)}:i(n(r))}if("string"===o)return i(function(n){const i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid number format: "${n}"`);return t(i)?e(i):i}(r));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(r),{gender:l="masculine"}=s,g="feminine"===l;let m="";return c&&(m=p+" "),m+=R(u,g),a&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=h,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=R(BigInt(r),n)),t}(a,g)),m}function B(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?N:w,s=n?E:I,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function P(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return B(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o="";return o=1===i?t:B(i,n)+" "+t,r>0&&(o+=" "+B(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s="";return s=1===r?i:B(r,n)+" "+i,o>0n&&(s+=" "+P(o,n)),s}function q(n,i){i=o(i);const r=function(n){const i=typeof n;if("bigint"===i){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"===i){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"===i)return function(n){const i=n.trim();if(0===i.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===i[0])throw new RangeError("Ordinals cannot be negative");if(i.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(i)){const n=e(i);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(i);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`)}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(n),{gender:s="masculine"}=i;return P(r,"feminine"===s)}function j(e,t){t=o(t);const{isNegative:i,dollars:s,cents:c}=function(e){const t=typeof e;if("bigint"===t)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===t){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:r(n(e))}if("string"===t)return r(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e),{and:u=!0}=t;let a="";return i&&(a=p+" "),(s>0n||0n===c)&&(a+=1n===s?"un euro":R(s,!1)+" euros"),c>0n&&(s>0n&&(a+=u?" con ":" "),a+=1n===c?"un céntimo":R(c,!1)+" céntimos"),a}export{x as toCardinal,j as toCurrency,q as toOrdinal};
1
+ /*! n2words/es-ES v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ function e(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function n(n){const i=n.toString();return t(i)?e(i):i}function t(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function r(n){let i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid currency format: "${n}"`);t(i)&&(i=e(i));const r="-"===i[0];r&&(i=i.slice(1));const o=i.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(i),cents:0n};const s=i.slice(0,o)||"0",c=(i.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function o(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const i=n.toString().length-1,r=n===10n**BigInt(i)?`10^${i} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${r}`)}function s(e){return 10n**BigInt(6*(e+1))}function c(e,n,t){const i={...n};if(void 0===e)return i;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[o,s]of Object.entries(e)){if(!Object.hasOwn(n,o))throw new TypeError(`Unknown option "${o}" — expected one of: ${r.join(", ")}`);if(void 0!==s){if(typeof s!=typeof i[o])throw new TypeError(`Option "${o}" must be a ${typeof i[o]}, got ${typeof s}`);if(void 0!==t&&Object.hasOwn(t,o)){const e=t[o];if(!e.includes(s))throw new RangeError(`Option "${o}" must be one of: ${e.join(", ")} — got ${JSON.stringify(s)}`)}i[o]=s}}return i}const u=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],a=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],g=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],l=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],f=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],m=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],d=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],v=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],p=["millón","billón","trillón","cuatrillón"],b=["millones","billones","trillones","cuatrillones"],h=s(p.length),w=10n**BigInt(9),N=s(p.length),y="mil",I="cero",E="menos",O=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],R=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],B=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],$=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function x(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?v:d)[r]),0===o||s.push(o<10?(n?a:u)[o]:o<20?g[t]:o<30?(n?f:l)[t]:0===t?m[i]:m[i]+" y "+(n?a:u)[t]),s.join(" ")}function j(e,n){if(1===e)return y;if(e%2==0){const t=e/2-1,i=p[t];return i?n>1n?b[t]:i:""}{const n=b[(e-1)/2-1];return n?y+" "+n:y}}function P(e,n){if(0n===e)return I;if(e<1000n)return x(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=y;else{const e=x(t,!1);r="uno"===e||"una"===e?y:e+" "+y}return i>0&&(r+=" "+x(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?j(e,i):"";r&&(r+=" "),r+=0===e?x(Number(i),n):1===e?1n===i?y:x(Number(i),!1)+" "+o:e%2==1?1n===i?o:x(Number(i),!1)+" "+o:1n===i?"un "+o:x(Number(i),!1)+" "+o}return r}(e,n)}const q={gender:"masculine"},T={gender:["masculine","feminine"]};function S(r,s){const{isNegative:u,integerPart:a,decimalPart:g}=function(r){const o=typeof r;if("bigint"==typeof r)return r<0n?{isNegative:!0,integerPart:-r}:{isNegative:!1,integerPart:r};if("number"==typeof r){if(!Number.isFinite(r))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(r)?r<0?{isNegative:!0,integerPart:BigInt(-r)}:{isNegative:!1,integerPart:BigInt(r)}:i(n(r))}if("string"==typeof r)return i(function(n){const i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid number format: "${n}"`);return t(i)?e(i):i}(r));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(r);o(a,h,g);const{gender:l}=c(s,q,T),f="feminine"===l;let m="";return u&&(m=E+" "),m+=P(a,f),g&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=I,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=P(BigInt(r),n)),t}(g,f)),m}function M(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?R:O,s=n?$:B,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function F(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return M(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o;return o=1===i?t:M(i,n)+" "+t,r>0&&(o+=" "+M(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s;return s=1===r?i:M(r,n)+" "+i,o>0n&&(s+=" "+F(o,n)),s}const k={gender:"masculine"},C={gender:["masculine","feminine"]};function z(n,i){const r=function(n){const i=typeof n;if("bigint"==typeof n){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"==typeof n){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"==typeof n)return function(n){const i=n.trim();if(0===i.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===i[0])throw new RangeError("Ordinals cannot be negative");if(i.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(i)){const n=e(i);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(i);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`,{cause:e})}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(n);o(r,w);const{gender:s}=c(i,k,C);return F(r,"feminine"===s)}const J={and:!0};function L(e,t){const{isNegative:i,dollars:s,cents:u}=function(e){const t=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:r(n(e))}if("string"==typeof e)return r(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);o(s,N);const{and:a}=c(t,J);let g="";return i&&(g=E+" "),(s>0n||0n===u)&&(g+=1n===s?"un euro":P(s,!1)+" euros"),u>0n&&(s>0n&&(g+=a?" con ":" "),g+=1n===u?"un céntimo":P(u,!1)+" céntimos"),g}export{q as cardinalDefaults,h as cardinalMax,T as cardinalValues,J as currencyDefaults,N as currencyMax,k as ordinalDefaults,w as ordinalMax,C as ordinalValues,S as toCardinal,L as toCurrency,z as toOrdinal};
package/dist/es-ES.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/es-ES v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function t(e){const t=e.toString();return i(t)?n(t):t}function i(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);i(t)&&(t=n(t));const r="-"===t[0];r&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",c=(t.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function s(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}const c=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],u=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],a=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],l=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],g=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],f=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],m=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],d=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],v=["millón","billón","trillón","cuatrillón"],b=["millones","billones","trillones","cuatrillones"],h="mil",p="cero",w="menos",N=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],y=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],I=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],E=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function O(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?d:m)[r]),0===o||s.push(o<10?(n?u:c)[o]:o<20?a[t]:o<30?(n?g:l)[t]:0===t?f[i]:f[i]+" y "+(n?u:c)[t]),s.join(" ")}function R(e,n){if(1===e)return h;if(e%2==0){const t=e/2-1,i=v[t];return i?n>1n?b[t]:i:""}{const n=b[(e-1)/2-1];return n?h+" "+n:h}}function x(e,n){if(0n===e)return p;if(e<1000n)return O(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=h;else{const e=O(t,!1);r="uno"===e||"una"===e?h:e+" "+h}return i>0&&(r+=" "+O(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?R(e,i):"";r&&(r+=" "),r+=0===e?O(Number(i),n):1===e?1n===i?h:O(Number(i),!1)+" "+o:e%2==1?1n===i?o:O(Number(i),!1)+" "+o:1n===i?"un "+o:O(Number(i),!1)+" "+o}return r}(e,n)}function B(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?y:N,s=n?E:I,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function P(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return B(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o="";return o=1===i?t:B(i,n)+" "+t,r>0&&(o+=" "+B(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s="";return s=1===r?i:B(r,n)+" "+i,o>0n&&(s+=" "+P(o,n)),s}const q={esES:function(e,t){t=s(t);const r=function(e){const t=typeof e;if("bigint"===t){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"===t){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"===t)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(i(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const i=BigInt(e);if(i<=0n)throw new RangeError("Ordinals must be positive integers");return i}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`)}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e),{gender:o="masculine"}=t;return P(r,"feminine"===o)}};e.currency={esES:function(e,n){n=s(n);const{isNegative:i,dollars:r,cents:c}=function(e){const n=typeof e;if("bigint"===n)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===n){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"===n)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e),{and:u=!0}=n;let a="";return i&&(a=w+" "),(r>0n||0n===c)&&(a+=1n===r?"un euro":x(r,!1)+" euros"),c>0n&&(r>0n&&(a+=u?" con ":" "),a+=1n===c?"un céntimo":x(c,!1)+" céntimos"),a}},e.esES=function(e,o){o=s(o);const{isNegative:c,integerPart:u,decimalPart:a}=function(e){const o=typeof e;if("bigint"===o)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===o){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:r(t(e))}if("string"===o)return r(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return i(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e),{gender:l="masculine"}=o,g="feminine"===l;let f="";return c&&(f=w+" "),f+=x(u,g),a&&(f+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=p,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=x(BigInt(r),n)),t}(a,g)),f},e.ordinal=q},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/es-ES v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function t(e){const t=e.toString();return i(t)?n(t):t}function i(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);i(t)&&(t=n(t));const r="-"===t[0];r&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",c=(t.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function s(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const i=n.toString().length-1,r=n===10n**BigInt(i)?`10^${i} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${r}`)}function c(e){return 10n**BigInt(6*(e+1))}function u(e,n,t){const i={...n};if(void 0===e)return i;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[o,s]of Object.entries(e)){if(!Object.hasOwn(n,o))throw new TypeError(`Unknown option "${o}" — expected one of: ${r.join(", ")}`);if(void 0!==s){if(typeof s!=typeof i[o])throw new TypeError(`Option "${o}" must be a ${typeof i[o]}, got ${typeof s}`);if(void 0!==t&&Object.hasOwn(t,o)){const e=t[o];if(!e.includes(s))throw new RangeError(`Option "${o}" must be one of: ${e.join(", ")} — got ${JSON.stringify(s)}`)}i[o]=s}}return i}const a=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],f=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],l=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],g=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],m=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],d=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],p=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],v=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],b=["millón","billón","trillón","cuatrillón"],h=["millones","billones","trillones","cuatrillones"],w=c(b.length),N=10n**BigInt(9),y=c(b.length),I="mil",E="cero",O="menos",R=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],B=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],x=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],$=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function j(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?v:p)[r]),0===o||s.push(o<10?(n?f:a)[o]:o<20?l[t]:o<30?(n?m:g)[t]:0===t?d[i]:d[i]+" y "+(n?f:a)[t]),s.join(" ")}function P(e,n){if(1===e)return I;if(e%2==0){const t=e/2-1,i=b[t];return i?n>1n?h[t]:i:""}{const n=h[(e-1)/2-1];return n?I+" "+n:I}}function q(e,n){if(0n===e)return E;if(e<1000n)return j(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=I;else{const e=j(t,!1);r="uno"===e||"una"===e?I:e+" "+I}return i>0&&(r+=" "+j(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?P(e,i):"";r&&(r+=" "),r+=0===e?j(Number(i),n):1===e?1n===i?I:j(Number(i),!1)+" "+o:e%2==1?1n===i?o:j(Number(i),!1)+" "+o:1n===i?"un "+o:j(Number(i),!1)+" "+o}return r}(e,n)}const S={gender:"masculine"},T={gender:["masculine","feminine"]};function M(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?B:R,s=n?$:x,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function F(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return M(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o;return o=1===i?t:M(i,n)+" "+t,r>0&&(o+=" "+M(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s;return s=1===r?i:M(r,n)+" "+i,o>0n&&(s+=" "+F(o,n)),s}const k={gender:"masculine"},C={gender:["masculine","feminine"]},z={and:!0},J={esES:function(e,t){const r=function(e){const t=typeof e;if("bigint"==typeof e){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"==typeof e)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(i(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const i=BigInt(e);if(i<=0n)throw new RangeError("Ordinals must be positive integers");return i}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`,{cause:n})}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);s(r,N);const{gender:o}=u(t,k,C);return F(r,"feminine"===o)}};e.currency={esES:function(e,n){const{isNegative:i,dollars:r,cents:c}=function(e){const n=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"==typeof e)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e);s(r,y);const{and:a}=u(n,z);let f="";return i&&(f=O+" "),(r>0n||0n===c)&&(f+=1n===r?"un euro":q(r,!1)+" euros"),c>0n&&(r>0n&&(f+=a?" con ":" "),f+=1n===c?"un céntimo":q(c,!1)+" céntimos"),f}},e.esES=function(e,o){const{isNegative:c,integerPart:a,decimalPart:f}=function(e){const o=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:r(t(e))}if("string"==typeof e)return r(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return i(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e);s(a,w,f);const{gender:l}=u(o,S,T),g="feminine"===l;let m="";return c&&(m=O+" "),m+=q(a,g),f&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=E,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=q(BigInt(r),n)),t}(f,g)),m},e.ordinal=J},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
package/dist/es-MX.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/es-MX v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- function e(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function n(n){const i=n.toString();return t(i)?e(i):i}function t(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function r(n){let i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid currency format: "${n}"`);t(i)&&(i=e(i));const r="-"===i[0];r&&(i=i.slice(1));const o=i.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(i),cents:0n};const s=i.slice(0,o)||"0",c=(i.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function o(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}const s=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],c=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],u=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],a=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],l=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],g=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],m=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],f=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],d=["millón","billón","trillón","cuatrillón"],v=["millones","billones","trillones","cuatrillones"],b="mil",h="cero",p="menos",w=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],N=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],I=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],E=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function y(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,d=[];return r>0&&d.push((n?f:m)[r]),0===o||d.push(o<10?(n?c:s)[o]:o<20?u[t]:o<30?(n?l:a)[t]:0===t?g[i]:g[i]+" y "+(n?c:s)[t]),d.join(" ")}function O(e,n){if(1===e)return b;if(e%2==0){const t=e/2-1,i=d[t];return i?n>1n?v[t]:i:""}{const n=v[(e-1)/2-1];return n?b+" "+n:b}}function R(e,n){if(0n===e)return h;if(e<1000n)return y(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=b;else{const e=y(t,!1);r="uno"===e||"una"===e?b:e+" "+b}return i>0&&(r+=" "+y(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?O(e,i):"";r&&(r+=" "),r+=0===e?y(Number(i),n):1===e?1n===i?b:y(Number(i),!1)+" "+o:e%2==1?1n===i?o:y(Number(i),!1)+" "+o:1n===i?"un "+o:y(Number(i),!1)+" "+o}return r}(e,n)}function x(r,s){s=o(s);const{isNegative:c,integerPart:u,decimalPart:a}=function(r){const o=typeof r;if("bigint"===o)return r<0n?{isNegative:!0,integerPart:-r}:{isNegative:!1,integerPart:r};if("number"===o){if(!Number.isFinite(r))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(r)?r<0?{isNegative:!0,integerPart:BigInt(-r)}:{isNegative:!1,integerPart:BigInt(r)}:i(n(r))}if("string"===o)return i(function(n){const i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid number format: "${n}"`);return t(i)?e(i):i}(r));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(r),{gender:l="masculine"}=s,g="feminine"===l;let m="";return c&&(m=p+" "),m+=R(u,g),a&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=h,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=R(BigInt(r),n)),t}(a,g)),m}function B(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?N:w,s=n?E:I,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function P(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return B(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o="";return o=1===i?t:B(i,n)+" "+t,r>0&&(o+=" "+B(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s="";return s=1===r?i:B(r,n)+" "+i,o>0n&&(s+=" "+P(o,n)),s}function q(n,i){i=o(i);const r=function(n){const i=typeof n;if("bigint"===i){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"===i){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"===i)return function(n){const i=n.trim();if(0===i.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===i[0])throw new RangeError("Ordinals cannot be negative");if(i.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(i)){const n=e(i);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(i);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`)}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(n),{gender:s="masculine"}=i;return P(r,"feminine"===s)}function j(e,t){t=o(t);const{isNegative:i,dollars:s,cents:c}=function(e){const t=typeof e;if("bigint"===t)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===t){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:r(n(e))}if("string"===t)return r(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e),{and:u=!0}=t;let a="";return i&&(a=p+" "),(s>0n||0n===c)&&(a+=1n===s?"un peso":R(s,!1)+" pesos"),c>0n&&(s>0n&&(a+=u?" con ":" "),a+=1n===c?"un centavo":R(c,!1)+" centavos"),a}export{x as toCardinal,j as toCurrency,q as toOrdinal};
1
+ /*! n2words/es-MX v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ function e(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function n(n){const i=n.toString();return t(i)?e(i):i}function t(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function r(n){let i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid currency format: "${n}"`);t(i)&&(i=e(i));const r="-"===i[0];r&&(i=i.slice(1));const o=i.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(i),cents:0n};const s=i.slice(0,o)||"0",c=(i.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function o(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const i=n.toString().length-1,r=n===10n**BigInt(i)?`10^${i} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${r}`)}function s(e){return 10n**BigInt(6*(e+1))}function c(e,n,t){const i={...n};if(void 0===e)return i;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[o,s]of Object.entries(e)){if(!Object.hasOwn(n,o))throw new TypeError(`Unknown option "${o}" — expected one of: ${r.join(", ")}`);if(void 0!==s){if(typeof s!=typeof i[o])throw new TypeError(`Option "${o}" must be a ${typeof i[o]}, got ${typeof s}`);if(void 0!==t&&Object.hasOwn(t,o)){const e=t[o];if(!e.includes(s))throw new RangeError(`Option "${o}" must be one of: ${e.join(", ")} — got ${JSON.stringify(s)}`)}i[o]=s}}return i}const u=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],a=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],g=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],l=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],f=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],m=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],d=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],v=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],p=["millón","billón","trillón","cuatrillón"],b=["millones","billones","trillones","cuatrillones"],h=s(p.length),w=10n**BigInt(9),N=s(p.length),y="mil",I="cero",E="menos",O=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],R=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],B=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],$=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function x(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?v:d)[r]),0===o||s.push(o<10?(n?a:u)[o]:o<20?g[t]:o<30?(n?f:l)[t]:0===t?m[i]:m[i]+" y "+(n?a:u)[t]),s.join(" ")}function j(e,n){if(1===e)return y;if(e%2==0){const t=e/2-1,i=p[t];return i?n>1n?b[t]:i:""}{const n=b[(e-1)/2-1];return n?y+" "+n:y}}function P(e,n){if(0n===e)return I;if(e<1000n)return x(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=y;else{const e=x(t,!1);r="uno"===e||"una"===e?y:e+" "+y}return i>0&&(r+=" "+x(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?j(e,i):"";r&&(r+=" "),r+=0===e?x(Number(i),n):1===e?1n===i?y:x(Number(i),!1)+" "+o:e%2==1?1n===i?o:x(Number(i),!1)+" "+o:1n===i?"un "+o:x(Number(i),!1)+" "+o}return r}(e,n)}const q={gender:"masculine"},T={gender:["masculine","feminine"]};function S(r,s){const{isNegative:u,integerPart:a,decimalPart:g}=function(r){const o=typeof r;if("bigint"==typeof r)return r<0n?{isNegative:!0,integerPart:-r}:{isNegative:!1,integerPart:r};if("number"==typeof r){if(!Number.isFinite(r))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(r)?r<0?{isNegative:!0,integerPart:BigInt(-r)}:{isNegative:!1,integerPart:BigInt(r)}:i(n(r))}if("string"==typeof r)return i(function(n){const i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid number format: "${n}"`);return t(i)?e(i):i}(r));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(r);o(a,h,g);const{gender:l}=c(s,q,T),f="feminine"===l;let m="";return u&&(m=E+" "),m+=P(a,f),g&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=I,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=P(BigInt(r),n)),t}(g,f)),m}function M(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?R:O,s=n?$:B,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function F(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return M(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o;return o=1===i?t:M(i,n)+" "+t,r>0&&(o+=" "+M(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s;return s=1===r?i:M(r,n)+" "+i,o>0n&&(s+=" "+F(o,n)),s}const k={gender:"masculine"},C={gender:["masculine","feminine"]};function z(n,i){const r=function(n){const i=typeof n;if("bigint"==typeof n){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"==typeof n){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"==typeof n)return function(n){const i=n.trim();if(0===i.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===i[0])throw new RangeError("Ordinals cannot be negative");if(i.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(i)){const n=e(i);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(i);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`,{cause:e})}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(n);o(r,w);const{gender:s}=c(i,k,C);return F(r,"feminine"===s)}const J={and:!0};function L(e,t){const{isNegative:i,dollars:s,cents:u}=function(e){const t=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:r(n(e))}if("string"==typeof e)return r(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);o(s,N);const{and:a}=c(t,J);let g="";return i&&(g=E+" "),(s>0n||0n===u)&&(g+=1n===s?"un peso":P(s,!1)+" pesos"),u>0n&&(s>0n&&(g+=a?" con ":" "),g+=1n===u?"un centavo":P(u,!1)+" centavos"),g}export{q as cardinalDefaults,h as cardinalMax,T as cardinalValues,J as currencyDefaults,N as currencyMax,k as ordinalDefaults,w as ordinalMax,C as ordinalValues,S as toCardinal,L as toCurrency,z as toOrdinal};
package/dist/es-MX.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/es-MX v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function t(e){const t=e.toString();return i(t)?n(t):t}function i(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);i(t)&&(t=n(t));const r="-"===t[0];r&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",c=(t.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function s(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}const c=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],u=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],a=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],l=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],g=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],f=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],m=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],d=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],v=["millón","billón","trillón","cuatrillón"],b=["millones","billones","trillones","cuatrillones"],p="mil",h="cero",w="menos",N=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],y=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],I=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],E=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function O(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?d:m)[r]),0===o||s.push(o<10?(n?u:c)[o]:o<20?a[t]:o<30?(n?g:l)[t]:0===t?f[i]:f[i]+" y "+(n?u:c)[t]),s.join(" ")}function R(e,n){if(1===e)return p;if(e%2==0){const t=e/2-1,i=v[t];return i?n>1n?b[t]:i:""}{const n=b[(e-1)/2-1];return n?p+" "+n:p}}function x(e,n){if(0n===e)return h;if(e<1000n)return O(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=p;else{const e=O(t,!1);r="uno"===e||"una"===e?p:e+" "+p}return i>0&&(r+=" "+O(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?R(e,i):"";r&&(r+=" "),r+=0===e?O(Number(i),n):1===e?1n===i?p:O(Number(i),!1)+" "+o:e%2==1?1n===i?o:O(Number(i),!1)+" "+o:1n===i?"un "+o:O(Number(i),!1)+" "+o}return r}(e,n)}function B(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?y:N,s=n?E:I,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function P(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return B(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o="";return o=1===i?t:B(i,n)+" "+t,r>0&&(o+=" "+B(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s="";return s=1===r?i:B(r,n)+" "+i,o>0n&&(s+=" "+P(o,n)),s}const q={esMX:function(e,t){t=s(t);const r=function(e){const t=typeof e;if("bigint"===t){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"===t){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"===t)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(i(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const i=BigInt(e);if(i<=0n)throw new RangeError("Ordinals must be positive integers");return i}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`)}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e),{gender:o="masculine"}=t;return P(r,"feminine"===o)}};e.currency={esMX:function(e,n){n=s(n);const{isNegative:i,dollars:r,cents:c}=function(e){const n=typeof e;if("bigint"===n)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===n){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"===n)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e),{and:u=!0}=n;let a="";return i&&(a=w+" "),(r>0n||0n===c)&&(a+=1n===r?"un peso":x(r,!1)+" pesos"),c>0n&&(r>0n&&(a+=u?" con ":" "),a+=1n===c?"un centavo":x(c,!1)+" centavos"),a}},e.esMX=function(e,o){o=s(o);const{isNegative:c,integerPart:u,decimalPart:a}=function(e){const o=typeof e;if("bigint"===o)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===o){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:r(t(e))}if("string"===o)return r(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return i(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e),{gender:l="masculine"}=o,g="feminine"===l;let f="";return c&&(f=w+" "),f+=x(u,g),a&&(f+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=h,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=x(BigInt(r),n)),t}(a,g)),f},e.ordinal=q},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/es-MX v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function t(e){const t=e.toString();return i(t)?n(t):t}function i(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);i(t)&&(t=n(t));const r="-"===t[0];r&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",c=(t.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function s(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const i=n.toString().length-1,r=n===10n**BigInt(i)?`10^${i} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${r}`)}function c(e){return 10n**BigInt(6*(e+1))}function u(e,n,t){const i={...n};if(void 0===e)return i;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[o,s]of Object.entries(e)){if(!Object.hasOwn(n,o))throw new TypeError(`Unknown option "${o}" — expected one of: ${r.join(", ")}`);if(void 0!==s){if(typeof s!=typeof i[o])throw new TypeError(`Option "${o}" must be a ${typeof i[o]}, got ${typeof s}`);if(void 0!==t&&Object.hasOwn(t,o)){const e=t[o];if(!e.includes(s))throw new RangeError(`Option "${o}" must be one of: ${e.join(", ")} — got ${JSON.stringify(s)}`)}i[o]=s}}return i}const a=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],f=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],l=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],g=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],m=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],d=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],p=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],v=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],b=["millón","billón","trillón","cuatrillón"],h=["millones","billones","trillones","cuatrillones"],w=c(b.length),N=10n**BigInt(9),y=c(b.length),I="mil",E="cero",O="menos",R=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],B=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],x=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],$=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function j(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?v:p)[r]),0===o||s.push(o<10?(n?f:a)[o]:o<20?l[t]:o<30?(n?m:g)[t]:0===t?d[i]:d[i]+" y "+(n?f:a)[t]),s.join(" ")}function P(e,n){if(1===e)return I;if(e%2==0){const t=e/2-1,i=b[t];return i?n>1n?h[t]:i:""}{const n=h[(e-1)/2-1];return n?I+" "+n:I}}function q(e,n){if(0n===e)return E;if(e<1000n)return j(Number(e),n);if(e<1000000n){const t=Number(e/1000n),i=Number(e%1000n);let r;if(1===t)r=I;else{const e=j(t,!1);r="uno"===e||"una"===e?I:e+" "+I}return i>0&&(r+=" "+j(i,n)),r}return function(e,n){const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n===i)continue;const o=e>0?P(e,i):"";r&&(r+=" "),r+=0===e?j(Number(i),n):1===e?1n===i?I:j(Number(i),!1)+" "+o:e%2==1?1n===i?o:j(Number(i),!1)+" "+o:1n===i?"un "+o:j(Number(i),!1)+" "+o}return r}(e,n)}const T={gender:"masculine"},M={gender:["masculine","feminine"]};function S(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?B:R,s=n?$:x,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function F(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return S(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o;return o=1===i?t:S(i,n)+" "+t,r>0&&(o+=" "+S(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s;return s=1===r?i:S(r,n)+" "+i,o>0n&&(s+=" "+F(o,n)),s}const X={gender:"masculine"},k={gender:["masculine","feminine"]},C={and:!0},z={esMX:function(e,t){const r=function(e){const t=typeof e;if("bigint"==typeof e){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"==typeof e)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(i(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const i=BigInt(e);if(i<=0n)throw new RangeError("Ordinals must be positive integers");return i}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`,{cause:n})}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);s(r,N);const{gender:o}=u(t,X,k);return F(r,"feminine"===o)}};e.currency={esMX:function(e,n){const{isNegative:i,dollars:r,cents:c}=function(e){const n=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"==typeof e)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e);s(r,y);const{and:a}=u(n,C);let f="";return i&&(f=O+" "),(r>0n||0n===c)&&(f+=1n===r?"un peso":q(r,!1)+" pesos"),c>0n&&(r>0n&&(f+=a?" con ":" "),f+=1n===c?"un centavo":q(c,!1)+" centavos"),f}},e.esMX=function(e,o){const{isNegative:c,integerPart:a,decimalPart:f}=function(e){const o=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:r(t(e))}if("string"==typeof e)return r(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return i(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e);s(a,w,f);const{gender:l}=u(o,T,M),g="feminine"===l;let m="";return c&&(m=O+" "),m+=q(a,g),f&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=E,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=q(BigInt(r),n)),t}(f,g)),m},e.ordinal=z},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
package/dist/es-US.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/es-US v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- function e(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function n(n){const i=n.toString();return t(i)?e(i):i}function t(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function r(n){let i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid currency format: "${n}"`);t(i)&&(i=e(i));const r="-"===i[0];r&&(i=i.slice(1));const o=i.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(i),cents:0n};const s=i.slice(0,o)||"0",c=(i.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function o(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}const s=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],c=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],u=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],a=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],l=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],g=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],m=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],f=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],d=["mil","millón","billón","trillón","cuatrillón","quintillón"],v=["mil","millones","billones","trillones","cuatrillones","quintillones"],b="cero",h="menos",p=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],w=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],N=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],I=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function E(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,d=[];return r>0&&d.push((n?f:m)[r]),0===o||d.push(o<10?(n?c:s)[o]:o<20?u[t]:o<30?(n?l:a)[t]:0===t?g[i]:g[i]+" y "+(n?c:s)[t]),d.join(" ")}function y(e,n){if(0n===e)return b;if(e<1000n)return E(Number(e),n);const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n!==i)if(r&&(r+=" "),0===e)r+=E(Number(i),n);else if(1===e)r+=1n===i?d[0]:E(Number(i),!1)+" "+d[0];else{const n=e-1;r+=n>=d.length?E(Number(i),!1):1n===i?"un "+d[n]:E(Number(i),!1)+" "+v[n]}}return r}function O(r,s){s=o(s);const{isNegative:c,integerPart:u,decimalPart:a}=function(r){const o=typeof r;if("bigint"===o)return r<0n?{isNegative:!0,integerPart:-r}:{isNegative:!1,integerPart:r};if("number"===o){if(!Number.isFinite(r))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(r)?r<0?{isNegative:!0,integerPart:BigInt(-r)}:{isNegative:!1,integerPart:BigInt(r)}:i(n(r))}if("string"===o)return i(function(n){const i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid number format: "${n}"`);return t(i)?e(i):i}(r));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(r),{gender:l="masculine"}=s,g="feminine"===l;let m="";return c&&(m=h+" "),m+=y(u,g),a&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=b,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=y(BigInt(r),n)),t}(a,g)),m}function R(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?w:p,s=n?I:N,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function x(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return R(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o="";return o=1===i?t:R(i,n)+" "+t,r>0&&(o+=" "+R(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s="";return s=1===r?i:R(r,n)+" "+i,o>0n&&(s+=" "+x(o,n)),s}function B(n,i){i=o(i);const r=function(n){const i=typeof n;if("bigint"===i){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"===i){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"===i)return function(n){const i=n.trim();if(0===i.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===i[0])throw new RangeError("Ordinals cannot be negative");if(i.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(i)){const n=e(i);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(i);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`)}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(n),{gender:s="masculine"}=i;return x(r,"feminine"===s)}function q(e,t){t=o(t);const{isNegative:i,dollars:s,cents:c}=function(e){const t=typeof e;if("bigint"===t)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===t){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:r(n(e))}if("string"===t)return r(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e),{and:u=!0}=t;let a="";return i&&(a=h+" "),(s>0n||0n===c)&&(a+=1n===s?"un dólar":y(s,!1)+" dólares"),c>0n&&(s>0n&&(a+=u?" con ":" "),a+=1n===c?"un centavo":y(c,!1)+" centavos"),a}export{O as toCardinal,q as toCurrency,B as toOrdinal};
1
+ /*! n2words/es-US v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ function e(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function n(n){const i=n.toString();return t(i)?e(i):i}function t(e){return e.includes("e")||e.includes("E")}function i(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function r(n){let i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid currency format: "${n}"`);t(i)&&(i=e(i));const r="-"===i[0];r&&(i=i.slice(1));const o=i.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(i),cents:0n};const s=i.slice(0,o)||"0",c=(i.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function o(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const i=n.toString().length-1,r=n===10n**BigInt(i)?`10^${i} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${r}`)}function s(e){return 10n**BigInt(3*(e+1))}function c(e,n,t){const i={...n};if(void 0===e)return i;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[o,s]of Object.entries(e)){if(!Object.hasOwn(n,o))throw new TypeError(`Unknown option "${o}" — expected one of: ${r.join(", ")}`);if(void 0!==s){if(typeof s!=typeof i[o])throw new TypeError(`Option "${o}" must be a ${typeof i[o]}, got ${typeof s}`);if(void 0!==t&&Object.hasOwn(t,o)){const e=t[o];if(!e.includes(s))throw new RangeError(`Option "${o}" must be one of: ${e.join(", ")} — got ${JSON.stringify(s)}`)}i[o]=s}}return i}const u=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],a=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],l=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],g=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],f=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],m=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],d=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],v=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],p=["mil","millón","billón","trillón","cuatrillón","quintillón"],b=["mil","millones","billones","trillones","cuatrillones","quintillones"],h=s(p.length),w=10n**BigInt(9),N=s(p.length),y="cero",I="menos",E=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],O=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],R=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],B=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function $(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?v:d)[r]),0===o||s.push(o<10?(n?a:u)[o]:o<20?l[t]:o<30?(n?f:g)[t]:0===t?m[i]:m[i]+" y "+(n?a:u)[t]),s.join(" ")}function x(e,n){if(0n===e)return y;if(e<1000n)return $(Number(e),n);const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n!==i)if(r&&(r+=" "),0===e)r+=$(Number(i),n);else if(1===e)r+=1n===i?p[0]:$(Number(i),!1)+" "+p[0];else{const n=e-1;r+=1n===i?"un "+p[n]:$(Number(i),!1)+" "+b[n]}}return r}const j={gender:"masculine"},q={gender:["masculine","feminine"]};function P(r,s){const{isNegative:u,integerPart:a,decimalPart:l}=function(r){const o=typeof r;if("bigint"==typeof r)return r<0n?{isNegative:!0,integerPart:-r}:{isNegative:!1,integerPart:r};if("number"==typeof r){if(!Number.isFinite(r))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(r)?r<0?{isNegative:!0,integerPart:BigInt(-r)}:{isNegative:!1,integerPart:BigInt(r)}:i(n(r))}if("string"==typeof r)return i(function(n){const i=n.trim();if(0===i.length||Number.isNaN(Number(i)))throw new RangeError(`Invalid number format: "${n}"`);return t(i)?e(i):i}(r));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(r);o(a,h,l);const{gender:g}=c(s,j,q),f="feminine"===g;let m="";return u&&(m=I+" "),m+=x(a,f),l&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=y,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=x(BigInt(r),n)),t}(l,f)),m}function T(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?O:E,s=n?B:R,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function S(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return T(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o;return o=1===i?t:T(i,n)+" "+t,r>0&&(o+=" "+T(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s;return s=1===r?i:T(r,n)+" "+i,o>0n&&(s+=" "+S(o,n)),s}const M={gender:"masculine"},F={gender:["masculine","feminine"]};function k(n,i){const r=function(n){const i=typeof n;if("bigint"==typeof n){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"==typeof n){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"==typeof n)return function(n){const i=n.trim();if(0===i.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===i[0])throw new RangeError("Ordinals cannot be negative");if(i.includes("."))throw new RangeError("Ordinals must be whole numbers");if(t(i)){const n=e(i);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const t=BigInt(n);if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}try{const e=BigInt(i);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`,{cause:e})}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${i}`)}(n);o(r,w);const{gender:s}=c(i,M,F);return S(r,"feminine"===s)}const C={and:!0};function z(e,t){const{isNegative:i,dollars:s,cents:u}=function(e){const t=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:r(n(e))}if("string"==typeof e)return r(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);o(s,N);const{and:a}=c(t,C);let l="";return i&&(l=I+" "),(s>0n||0n===u)&&(l+=1n===s?"un dólar":x(s,!1)+" dólares"),u>0n&&(s>0n&&(l+=a?" con ":" "),l+=1n===u?"un centavo":x(u,!1)+" centavos"),l}export{j as cardinalDefaults,h as cardinalMax,q as cardinalValues,C as currencyDefaults,N as currencyMax,M as ordinalDefaults,w as ordinalMax,F as ordinalValues,P as toCardinal,z as toCurrency,k as toOrdinal};
package/dist/es-US.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/es-US v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function t(e){const t=e.toString();return i(t)?n(t):t}function i(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);i(t)&&(t=n(t));const r="-"===t[0];r&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",c=(t.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function s(e){if(void 0===e)return{};if(function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))return e;throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e)}const c=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],u=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],a=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],l=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],g=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],f=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],m=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],d=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],v=["mil","millón","billón","trillón","cuatrillón","quintillón"],b=["mil","millones","billones","trillones","cuatrillones","quintillones"],h="cero",p="menos",w=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],N=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],y=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],I=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function E(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?d:m)[r]),0===o||s.push(o<10?(n?u:c)[o]:o<20?a[t]:o<30?(n?g:l)[t]:0===t?f[i]:f[i]+" y "+(n?u:c)[t]),s.join(" ")}function O(e,n){if(0n===e)return h;if(e<1000n)return E(Number(e),n);const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n!==i)if(r&&(r+=" "),0===e)r+=E(Number(i),n);else if(1===e)r+=1n===i?v[0]:E(Number(i),!1)+" "+v[0];else{const n=e-1;r+=n>=v.length?E(Number(i),!1):1n===i?"un "+v[n]:E(Number(i),!1)+" "+b[n]}}return r}function R(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?N:w,s=n?I:y,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function x(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return R(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o="";return o=1===i?t:R(i,n)+" "+t,r>0&&(o+=" "+R(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s="";return s=1===r?i:R(r,n)+" "+i,o>0n&&(s+=" "+x(o,n)),s}const B={esUS:function(e,t){t=s(t);const r=function(e){const t=typeof e;if("bigint"===t){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"===t){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"===t)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(i(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const i=BigInt(e);if(i<=0n)throw new RangeError("Ordinals must be positive integers");return i}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`)}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e),{gender:o="masculine"}=t;return x(r,"feminine"===o)}};e.currency={esUS:function(e,n){n=s(n);const{isNegative:i,dollars:r,cents:c}=function(e){const n=typeof e;if("bigint"===n)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===n){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"===n)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e),{and:u=!0}=n;let a="";return i&&(a=p+" "),(r>0n||0n===c)&&(a+=1n===r?"un dólar":O(r,!1)+" dólares"),c>0n&&(r>0n&&(a+=u?" con ":" "),a+=1n===c?"un centavo":O(c,!1)+" centavos"),a}},e.esUS=function(e,o){o=s(o);const{isNegative:c,integerPart:u,decimalPart:a}=function(e){const o=typeof e;if("bigint"===o)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"===o){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:r(t(e))}if("string"===o)return r(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return i(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e),{gender:l="masculine"}=o,g="feminine"===l;let f="";return c&&(f=p+" "),f+=O(u,g),a&&(f+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=h,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=O(BigInt(r),n)),t}(a,g)),f},e.ordinal=B},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
1
+ /*! n2words/es-US v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ var e,n;e=this,n=function(e){"use strict";function n(e){let[n,t]=e.toLowerCase().split("e");const i=parseInt(t,10);let r="";"-"===n[0]&&(r="-",n=n.slice(1));const o=n.indexOf("."),s=-1===o?n:n.slice(0,o)+n.slice(o+1),c=(-1===o?n.length:o)+i;return c>=s.length?r+s+"0".repeat(c-s.length):c<=0?r+"0."+"0".repeat(-c)+s:r+s.slice(0,c)+"."+s.slice(c)}function t(e){const t=e.toString();return i(t)?n(t):t}function i(e){return e.includes("e")||e.includes("E")}function r(e){const n="-"===e[0];n&&(e=e.slice(1));const t=e.indexOf(".");if(-1===t)return{isNegative:n,integerPart:BigInt(e)};const i=e.slice(0,t)||"0",r=e.slice(t+1);return{isNegative:n,integerPart:BigInt(i),decimalPart:r}}function o(e){let t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${e}"`);i(t)&&(t=n(t));const r="-"===t[0];r&&(t=t.slice(1));const o=t.indexOf(".");if(-1===o)return{isNegative:r,dollars:BigInt(t),cents:0n};const s=t.slice(0,o)||"0",c=(t.slice(o+1)+"00").slice(0,2);return{isNegative:r,dollars:BigInt(s),cents:BigInt(c)}}function s(e,n,t){if(null===n)return;if(e<n&&!(t&&BigInt(t)>=n))return;const i=n.toString().length-1,r=n===10n**BigInt(i)?`10^${i} - 1`:""+(n-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${r}`)}function c(e){return 10n**BigInt(3*(e+1))}function u(e,n,t){const i={...n};if(void 0===e)return i;if(!function(e){if(null===e||"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);return null===n||n===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(n);for(const[o,s]of Object.entries(e)){if(!Object.hasOwn(n,o))throw new TypeError(`Unknown option "${o}" — expected one of: ${r.join(", ")}`);if(void 0!==s){if(typeof s!=typeof i[o])throw new TypeError(`Option "${o}" must be a ${typeof i[o]}, got ${typeof s}`);if(void 0!==t&&Object.hasOwn(t,o)){const e=t[o];if(!e.includes(s))throw new RangeError(`Option "${o}" must be one of: ${e.join(", ")} — got ${JSON.stringify(s)}`)}i[o]=s}}return i}const a=["","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],l=["","una","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"],f=["diez","once","doce","trece","catorce","quince","dieciseis","diecisiete","dieciocho","diecinueve"],g=["veinte","veintiuno","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],m=["veinte","veintiuna","veintidós","veintitrés","veinticuatro","veinticinco","veintiséis","veintisiete","veintiocho","veintinueve"],d=["","","","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"],p=["","ciento","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"],v=["","cienta","doscientas","trescientas","cuatrocientas","quinientas","seiscientas","setecientas","ochocientas","novecientas"],b=["mil","millón","billón","trillón","cuatrillón","quintillón"],h=["mil","millones","billones","trillones","cuatrillones","quintillones"],w=c(b.length),y=10n**BigInt(9),N=c(b.length),I="cero",E="menos",O=["","primero","segundo","tercero","cuarto","quinto","sexto","séptimo","octavo","noveno"],R=["","primera","segunda","tercera","cuarta","quinta","sexta","séptima","octava","novena"],B=["","décimo","vigésimo","trigésimo","cuadragésimo","quincuagésimo","sexagésimo","septuagésimo","octogésimo","nonagésimo"],x=["","décima","vigésima","trigésima","cuadragésima","quincuagésima","sexagésima","septuagésima","octogésima","nonagésima"];function $(e,n){if(0===e)return"";if(100===e)return"cien";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=e%100,s=[];return r>0&&s.push((n?v:p)[r]),0===o||s.push(o<10?(n?l:a)[o]:o<20?f[t]:o<30?(n?m:g)[t]:0===t?d[i]:d[i]+" y "+(n?l:a)[t]),s.join(" ")}function j(e,n){if(0n===e)return I;if(e<1000n)return $(Number(e),n);const t=[];let i=e;for(;i>0n;)t.push(i%1000n),i/=1000n;let r="";for(let e=t.length-1;e>=0;e--){const i=t[e];if(0n!==i)if(r&&(r+=" "),0===e)r+=$(Number(i),n);else if(1===e)r+=1n===i?b[0]:$(Number(i),!1)+" "+b[0];else{const n=e-1;r+=1n===i?"un "+b[n]:$(Number(i),!1)+" "+h[n]}}return r}const q={gender:"masculine"},P={gender:["masculine","feminine"]};function S(e,n){if(0===e)return"";const t=e%10,i=Math.trunc(e/10)%10,r=Math.trunc(e/100),o=n?R:O,s=n?x:B,c=n?"centésima":"centésimo",u=[];return r>0&&u.push(1===r?c:["","","du","tri","cuadri","quin","sex","septi","octi","noni"][r]+c),i>0&&u.push(s[i]),t>0&&u.push(o[t]),u.join(" ")}function T(e,n){const t=n?"milésima":"milésimo",i=n?"millonésima":"millonésimo";if(e<1000n)return S(Number(e),n);if(e<1000000n){const i=Number(e/1000n),r=Number(e%1000n);let o;return o=1===i?t:S(i,n)+" "+t,r>0&&(o+=" "+S(r,n)),o}const r=Number(e/1000000n),o=e%1000000n;let s;return s=1===r?i:S(r,n)+" "+i,o>0n&&(s+=" "+T(o,n)),s}const M={gender:"masculine"},U={gender:["masculine","feminine"]},F={and:!0},k={esUS:function(e,t){const r=function(e){const t=typeof e;if("bigint"==typeof e){if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(e))throw new RangeError("Ordinals must be whole numbers");if(e<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(e)}if("string"==typeof e)return function(e){const t=e.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(i(t)){const e=n(t);if(e.includes("."))throw new RangeError("Ordinals must be whole numbers");const i=BigInt(e);if(i<=0n)throw new RangeError("Ordinals must be positive integers");return i}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(n){if(n instanceof RangeError)throw n;throw new RangeError(`Invalid ordinal format: "${e}"`,{cause:n})}}(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(e);s(r,y);const{gender:o}=u(t,M,U);return T(r,"feminine"===o)}};e.currency={esUS:function(e,n){const{isNegative:i,dollars:r,cents:c}=function(e){const n=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:o(t(e))}if("string"==typeof e)return o(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e);s(r,N);const{and:a}=u(n,F);let l="";return i&&(l=E+" "),(r>0n||0n===c)&&(l+=1n===r?"un dólar":j(r,!1)+" dólares"),c>0n&&(r>0n&&(l+=a?" con ":" "),l+=1n===c?"un centavo":j(c,!1)+" centavos"),l}},e.esUS=function(e,o){const{isNegative:c,integerPart:a,decimalPart:l}=function(e){const o=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,integerPart:-e}:{isNegative:!1,integerPart:e};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(e)?e<0?{isNegative:!0,integerPart:BigInt(-e)}:{isNegative:!1,integerPart:BigInt(e)}:r(t(e))}if("string"==typeof e)return r(function(e){const t=e.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${e}"`);return i(t)?n(t):t}(e));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(e);s(a,w,l);const{gender:f}=u(o,q,P),g="feminine"===f;let m="";return c&&(m=E+" "),m+=j(a,g),l&&(m+=" punto "+function(e,n){let t="",i=0;for(;i<e.length&&"0"===e[i];)t&&(t+=" "),t+=I,i++;const r=e.slice(i);return r&&(t&&(t+=" "),t+=j(BigInt(r),n)),t}(l,g)),m},e.ordinal=k},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).n2words=e.n2words||{});
package/dist/fa-IR.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! n2words/fa-IR v5.0.0 | MIT License | github.com/forzagreen/n2words */
2
- function e(e){let[n,r]=e.toLowerCase().split("e");const t=parseInt(r,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const s=n.indexOf("."),o=-1===s?n:n.slice(0,s)+n.slice(s+1),u=(-1===s?n.length:s)+t;return u>=o.length?i+o+"0".repeat(u-o.length):u<=0?i+"0."+"0".repeat(-u)+o:i+o.slice(0,u)+"."+o.slice(u)}function n(n){const t=n.toString();return r(t)?e(t):t}function r(e){return e.includes("e")||e.includes("E")}function t(e){const n="-"===e[0];n&&(e=e.slice(1));const r=e.indexOf(".");if(-1===r)return{isNegative:n,integerPart:BigInt(e)};const t=e.slice(0,r)||"0",i=e.slice(r+1);return{isNegative:n,integerPart:BigInt(t),decimalPart:i}}function i(n){let t=n.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${n}"`);r(t)&&(t=e(t));const i="-"===t[0];i&&(t=t.slice(1));const s=t.indexOf(".");if(-1===s)return{isNegative:i,dollars:BigInt(t),cents:0n};const o=t.slice(0,s)||"0",u=(t.slice(s+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(o),cents:BigInt(u)}}const s={1:"یک",2:"دو",3:"سه",4:"چهار",5:"پنج",6:"شش",7:"هفت",8:"هشت",9:"نه"},o={10:"ده",11:"یازده",12:"دوازده",13:"سیزده",14:"چهارده",15:"پانزده",16:"شانزده",17:"هفده",18:"هجده",19:"نوزده"},u={20:"بیست",30:"سی",40:"چهل",50:"پنجاه",60:"شصت",70:"هفتاد",80:"هشتاد",90:"نود"},a={100:"صد",200:"دویست",300:"سيصد",400:"چهار صد",500:"پانصد",600:"ششصد",700:"هفتصد",800:"هشتصد",900:"نهصد"},c="منفى",g={1:"اول",2:"دوم",3:"سوم",4:"چهارم",5:"پنجم",6:"ششم",7:"هفتم",8:"هشتم",9:"نهم"};function l(e){if(0n===e)return"صفر";if(e<=9n)return s[Number(e)];if(e<=19n)return o[Number(e)];if(e<100n){const n=e%10n,r=e-n;return 0n===n?u[Number(r)]:`${u[Number(r)]} و ${s[Number(n)]}`}if(e<1000n){const n=e/100n*100n,r=e-n;return 0n===r?a[Number(n)]:`${a[Number(n)]} و ${l(r)}`}if(e<1000000n){const n=e/1000n,r=e%1000n;return`${1n===n?"":l(n)+" "}هزار${0n===r?"":" "+l(r)}`}if(e<1000000000n){const n=e%1000000n;return`${l(e/1000000n)+" میلیون"}${0n===n?"":" و "+l(n)}`}const n=e%1000000000n;return`${l(e/1000000000n)+" میلیارد"}${0n===n?"":" و "+l(n)}`}function f(i){const{isNegative:s,integerPart:o,decimalPart:u}=function(i){const s=typeof i;if("bigint"===s)return i<0n?{isNegative:!0,integerPart:-i}:{isNegative:!1,integerPart:i};if("number"===s){if(!Number.isFinite(i))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(i)?i<0?{isNegative:!0,integerPart:BigInt(-i)}:{isNegative:!1,integerPart:BigInt(i)}:t(n(i))}if("string"===s)return t(function(n){const t=n.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${n}"`);return r(t)?e(t):t}(i));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${s}`)}(i);let a="";return s&&(a=c+" "),a+=l(o),u&&(a+=" ممیّز "+function(e){let n="",r=0;for(;r<e.length&&"0"===e[r];)n&&(n+=" "),n+="صفر",r++;const t=e.slice(r);return t&&(n&&(n+=" "),n+=l(BigInt(t))),n}(u)),a}function m(n){const t=function(n){const t=typeof n;if("bigint"===t){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"===t){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"===t)return function(n){const t=n.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(r(t)){const n=e(t);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const r=BigInt(n);if(r<=0n)throw new RangeError("Ordinals must be positive integers");return r}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`)}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(n);return(i=t)>=1n&&i<=9n?g[Number(i)]:l(i)+"م";var i}function b(e){const{isNegative:r,dollars:t}=function(e){const r=typeof e;if("bigint"===r)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"===r){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:i(n(e))}if("string"===r)return i(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(e);let s="";return r&&(s=c+" "),s+=l(t),s+=" ریال",s}export{f as toCardinal,b as toCurrency,m as toOrdinal};
1
+ /*! n2words/fa-IR v5.1.1 | MIT License | github.com/forzagreen/n2words */
2
+ function e(e){let[n,r]=e.toLowerCase().split("e");const t=parseInt(r,10);let i="";"-"===n[0]&&(i="-",n=n.slice(1));const s=n.indexOf("."),o=-1===s?n:n.slice(0,s)+n.slice(s+1),u=(-1===s?n.length:s)+t;return u>=o.length?i+o+"0".repeat(u-o.length):u<=0?i+"0."+"0".repeat(-u)+o:i+o.slice(0,u)+"."+o.slice(u)}function n(n){const t=n.toString();return r(t)?e(t):t}function r(e){return e.includes("e")||e.includes("E")}function t(e){const n="-"===e[0];n&&(e=e.slice(1));const r=e.indexOf(".");if(-1===r)return{isNegative:n,integerPart:BigInt(e)};const t=e.slice(0,r)||"0",i=e.slice(r+1);return{isNegative:n,integerPart:BigInt(t),decimalPart:i}}function i(n){let t=n.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid currency format: "${n}"`);r(t)&&(t=e(t));const i="-"===t[0];i&&(t=t.slice(1));const s=t.indexOf(".");if(-1===s)return{isNegative:i,dollars:BigInt(t),cents:0n};const o=t.slice(0,s)||"0",u=(t.slice(s+1)+"00").slice(0,2);return{isNegative:i,dollars:BigInt(o),cents:BigInt(u)}}const s=null,o=s,u=s,a=s,c={1:"یک",2:"دو",3:"سه",4:"چهار",5:"پنج",6:"شش",7:"هفت",8:"هشت",9:"نه"},g={10:"ده",11:"یازده",12:"دوازده",13:"سیزده",14:"چهارده",15:"پانزده",16:"شانزده",17:"هفده",18:"هجده",19:"نوزده"},f={20:"بیست",30:"سی",40:"چهل",50:"پنجاه",60:"شصت",70:"هفتاد",80:"هشتاد",90:"نود"},l={100:"صد",200:"دویست",300:"سيصد",400:"چهار صد",500:"پانصد",600:"ششصد",700:"هفتصد",800:"هشتصد",900:"نهصد"},m="منفى",b={1:"اول",2:"دوم",3:"سوم",4:"چهارم",5:"پنجم",6:"ششم",7:"هفتم",8:"هشتم",9:"نهم"};function d(e){if(0n===e)return"صفر";if(e<=9n)return c[Number(e)];if(e<=19n)return g[Number(e)];if(e<100n){const n=e%10n,r=e-n;return 0n===n?f[Number(r)]:`${f[Number(r)]} و ${c[Number(n)]}`}if(e<1000n){const n=e/100n*100n,r=e-n;return 0n===r?l[Number(n)]:`${l[Number(n)]} و ${d(r)}`}if(e<1000000n){const n=e/1000n,r=e%1000n;return`${1n===n?"":d(n)+" "}هزار${0n===r?"":" "+d(r)}`}if(e<1000000000n){const n=e%1000000n;return`${d(e/1000000n)+" میلیون"}${0n===n?"":" و "+d(n)}`}const n=e%1000000000n;return`${d(e/1000000000n)+" میلیارد"}${0n===n?"":" و "+d(n)}`}function w(i){const{isNegative:s,integerPart:o,decimalPart:u}=function(i){const s=typeof i;if("bigint"==typeof i)return i<0n?{isNegative:!0,integerPart:-i}:{isNegative:!1,integerPart:i};if("number"==typeof i){if(!Number.isFinite(i))throw new RangeError("Number must be finite (NaN and Infinity are not supported)");return Number.isSafeInteger(i)?i<0?{isNegative:!0,integerPart:BigInt(-i)}:{isNegative:!1,integerPart:BigInt(i)}:t(n(i))}if("string"==typeof i)return t(function(n){const t=n.trim();if(0===t.length||Number.isNaN(Number(t)))throw new RangeError(`Invalid number format: "${n}"`);return r(t)?e(t):t}(i));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${s}`)}(i);let a="";return s&&(a=m+" "),a+=d(o),u&&(a+=" ممیّز "+function(e){let n="",r=0;for(;r<e.length&&"0"===e[r];)n&&(n+=" "),n+="صفر",r++;const t=e.slice(r);return t&&(n&&(n+=" "),n+=d(BigInt(t))),n}(u)),a}function N(n){const t=function(n){const t=typeof n;if("bigint"==typeof n){if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}if("number"==typeof n){if(!Number.isFinite(n))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(n))throw new RangeError("Ordinals must be whole numbers");if(n<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(n)}if("string"==typeof n)return function(n){const t=n.trim();if(0===t.length)throw new RangeError("Ordinals cannot be empty strings");if("-"===t[0])throw new RangeError("Ordinals cannot be negative");if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");if(r(t)){const n=e(t);if(n.includes("."))throw new RangeError("Ordinals must be whole numbers");const r=BigInt(n);if(r<=0n)throw new RangeError("Ordinals must be positive integers");return r}try{const e=BigInt(t);if(e<=0n)throw new RangeError("Ordinals must be positive integers");return e}catch(e){if(e instanceof RangeError)throw e;throw new RangeError(`Invalid ordinal format: "${n}"`,{cause:e})}}(n);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${t}`)}(n);return(i=t)>=1n&&i<=9n?b[Number(i)]:d(i)+"م";var i}function p(e){const{isNegative:r,dollars:t}=function(e){const r=typeof e;if("bigint"==typeof e)return e<0n?{isNegative:!0,dollars:-e,cents:0n}:{isNegative:!1,dollars:e,cents:0n};if("number"==typeof e){if(!Number.isFinite(e))throw new RangeError("Currency must be a finite number");return Number.isSafeInteger(e)?e<0?{isNegative:!0,dollars:BigInt(-e),cents:0n}:{isNegative:!1,dollars:BigInt(e),cents:0n}:i(n(e))}if("string"==typeof e)return i(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(e);let s="";return r&&(s=m+" "),s+=d(t),s+=" ریال",s}export{o as cardinalMax,a as currencyMax,u as ordinalMax,w as toCardinal,p as toCurrency,N as toOrdinal};