n2words 4.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +14 -12
- package/dist/am-ET.js +2 -2
- package/dist/am-ET.umd.js +2 -2
- package/dist/am-Latn-ET.js +2 -2
- package/dist/am-Latn-ET.umd.js +2 -2
- package/dist/ar-SA.js +2 -2
- package/dist/ar-SA.umd.js +2 -2
- package/dist/az-AZ.js +2 -2
- package/dist/az-AZ.umd.js +2 -2
- package/dist/bn-BD.js +2 -2
- package/dist/bn-BD.umd.js +2 -2
- package/dist/cs-CZ.js +2 -2
- package/dist/cs-CZ.umd.js +2 -2
- package/dist/da-DK.js +2 -2
- package/dist/da-DK.umd.js +2 -2
- package/dist/de-DE.js +2 -2
- package/dist/de-DE.umd.js +2 -2
- package/dist/el-GR.js +2 -2
- package/dist/el-GR.umd.js +2 -2
- package/dist/en-AU.js +2 -2
- package/dist/en-AU.umd.js +2 -2
- package/dist/en-BD.js +2 -2
- package/dist/en-BD.umd.js +2 -2
- package/dist/en-CA.js +2 -2
- package/dist/en-CA.umd.js +2 -2
- package/dist/en-GB.js +2 -2
- package/dist/en-GB.umd.js +2 -2
- package/dist/en-GH.js +2 -2
- package/dist/en-GH.umd.js +2 -2
- package/dist/en-IE.js +2 -2
- package/dist/en-IE.umd.js +2 -2
- package/dist/en-IN.js +2 -2
- package/dist/en-IN.umd.js +2 -2
- package/dist/en-KE.js +2 -2
- package/dist/en-KE.umd.js +2 -2
- package/dist/en-MY.js +2 -2
- package/dist/en-MY.umd.js +2 -2
- package/dist/en-NG.js +2 -2
- package/dist/en-NG.umd.js +2 -2
- package/dist/en-NZ.js +2 -2
- package/dist/en-NZ.umd.js +2 -2
- package/dist/en-PH.js +2 -2
- package/dist/en-PH.umd.js +2 -2
- package/dist/en-PK.js +2 -2
- package/dist/en-PK.umd.js +2 -2
- package/dist/en-SG.js +2 -2
- package/dist/en-SG.umd.js +2 -2
- package/dist/en-US.js +2 -2
- package/dist/en-US.umd.js +2 -2
- package/dist/en-ZA.js +2 -2
- package/dist/en-ZA.umd.js +2 -2
- package/dist/es-ES.js +2 -2
- package/dist/es-ES.umd.js +2 -2
- package/dist/es-MX.js +2 -2
- package/dist/es-MX.umd.js +2 -2
- package/dist/es-US.js +2 -2
- package/dist/es-US.umd.js +2 -2
- package/dist/fa-IR.js +2 -2
- package/dist/fa-IR.umd.js +2 -2
- package/dist/fi-FI.js +2 -2
- package/dist/fi-FI.umd.js +2 -2
- package/dist/fil-PH.js +2 -2
- package/dist/fil-PH.umd.js +2 -2
- package/dist/fr-BE.js +2 -2
- package/dist/fr-BE.umd.js +2 -2
- package/dist/fr-FR.js +2 -2
- package/dist/fr-FR.umd.js +2 -2
- package/dist/gu-IN.js +2 -2
- package/dist/gu-IN.umd.js +2 -2
- package/dist/ha-NG.js +2 -2
- package/dist/ha-NG.umd.js +2 -2
- package/dist/hbo-IL.js +2 -2
- package/dist/hbo-IL.umd.js +2 -2
- package/dist/he-IL.js +2 -2
- package/dist/he-IL.umd.js +2 -2
- package/dist/hi-IN.js +2 -2
- package/dist/hi-IN.umd.js +2 -2
- package/dist/hr-HR.js +2 -2
- package/dist/hr-HR.umd.js +2 -2
- package/dist/hu-HU.js +2 -2
- package/dist/hu-HU.umd.js +2 -2
- package/dist/id-ID.js +2 -2
- package/dist/id-ID.umd.js +2 -2
- package/dist/it-IT.js +2 -2
- package/dist/it-IT.umd.js +2 -2
- package/dist/ja-JP.js +2 -2
- package/dist/ja-JP.umd.js +2 -2
- package/dist/ka-GE.js +2 -2
- package/dist/ka-GE.umd.js +2 -2
- package/dist/kn-IN.js +2 -2
- package/dist/kn-IN.umd.js +2 -2
- package/dist/ko-KR.js +2 -2
- package/dist/ko-KR.umd.js +2 -2
- package/dist/lt-LT.js +2 -2
- package/dist/lt-LT.umd.js +2 -2
- package/dist/lv-LV.js +2 -2
- package/dist/lv-LV.umd.js +2 -2
- package/dist/mr-IN.js +2 -2
- package/dist/mr-IN.umd.js +2 -2
- package/dist/ms-MY.js +2 -2
- package/dist/ms-MY.umd.js +2 -2
- package/dist/nb-NO.js +2 -2
- package/dist/nb-NO.umd.js +2 -2
- package/dist/nl-NL.js +2 -2
- package/dist/nl-NL.umd.js +2 -2
- package/dist/pa-IN.js +2 -2
- package/dist/pa-IN.umd.js +2 -2
- package/dist/pl-PL.js +2 -2
- package/dist/pl-PL.umd.js +2 -2
- package/dist/pt-BR.js +2 -0
- package/dist/pt-BR.umd.js +2 -0
- package/dist/pt-PT.js +2 -2
- package/dist/pt-PT.umd.js +2 -2
- package/dist/ro-RO.js +2 -2
- package/dist/ro-RO.umd.js +2 -2
- package/dist/ru-RU.js +2 -2
- package/dist/ru-RU.umd.js +2 -2
- package/dist/sr-Cyrl-RS.js +2 -2
- package/dist/sr-Cyrl-RS.umd.js +2 -2
- package/dist/sr-Latn-RS.js +2 -2
- package/dist/sr-Latn-RS.umd.js +2 -2
- package/dist/sv-SE.js +2 -2
- package/dist/sv-SE.umd.js +2 -2
- package/dist/sw-KE.js +2 -2
- package/dist/sw-KE.umd.js +2 -2
- package/dist/ta-IN.js +2 -2
- package/dist/ta-IN.umd.js +2 -2
- package/dist/te-IN.js +2 -2
- package/dist/te-IN.umd.js +2 -2
- package/dist/th-TH.js +2 -2
- package/dist/th-TH.umd.js +2 -2
- package/dist/tr-TR.js +2 -2
- package/dist/tr-TR.umd.js +2 -2
- package/dist/uk-UA.js +2 -2
- package/dist/uk-UA.umd.js +2 -2
- package/dist/ur-PK.js +2 -2
- package/dist/ur-PK.umd.js +2 -2
- package/dist/vi-VN.js +2 -2
- package/dist/vi-VN.umd.js +2 -2
- package/dist/yo-NG.js +2 -2
- package/dist/yo-NG.umd.js +2 -2
- package/dist/zh-Hans-CN.js +2 -2
- package/dist/zh-Hans-CN.umd.js +2 -2
- package/dist/zh-Hant-TW.js +2 -2
- package/dist/zh-Hant-TW.umd.js +2 -2
- package/package.json +53 -36
- package/src/am-ET.d.ts +3 -5
- package/src/am-ET.js +41 -16
- package/src/am-Latn-ET.d.ts +3 -5
- package/src/am-Latn-ET.js +45 -16
- package/src/ar-SA.d.ts +44 -18
- package/src/ar-SA.js +93 -40
- package/src/az-AZ.d.ts +3 -5
- package/src/az-AZ.js +58 -20
- package/src/bn-BD.d.ts +3 -5
- package/src/bn-BD.js +32 -16
- package/src/cs-CZ.d.ts +3 -6
- package/src/cs-CZ.js +66 -42
- package/src/da-DK.d.ts +3 -6
- package/src/da-DK.js +53 -48
- package/src/de-DE.d.ts +17 -11
- package/src/de-DE.js +88 -57
- package/src/el-GR.d.ts +3 -6
- package/src/el-GR.js +45 -32
- package/src/en-AU.d.ts +17 -11
- package/src/en-AU.js +56 -41
- package/src/en-BD.d.ts +17 -11
- package/src/en-BD.js +60 -41
- package/src/en-CA.d.ts +36 -18
- package/src/en-CA.js +67 -46
- package/src/en-GB.d.ts +17 -11
- package/src/en-GB.js +56 -41
- package/src/en-GH.d.ts +32 -3
- package/src/en-GH.js +104 -26
- package/src/en-IE.d.ts +17 -11
- package/src/en-IE.js +56 -41
- package/src/en-IN.d.ts +17 -11
- package/src/en-IN.js +60 -41
- package/src/en-KE.d.ts +28 -3
- package/src/en-KE.js +93 -26
- package/src/en-MY.d.ts +26 -3
- package/src/en-MY.js +91 -26
- package/src/en-NG.d.ts +17 -11
- package/src/en-NG.js +56 -41
- package/src/en-NZ.d.ts +32 -3
- package/src/en-NZ.js +85 -31
- package/src/en-PH.d.ts +32 -3
- package/src/en-PH.js +97 -26
- package/src/en-PK.d.ts +17 -11
- package/src/en-PK.js +60 -41
- package/src/en-SG.d.ts +28 -3
- package/src/en-SG.js +93 -26
- package/src/en-US.d.ts +36 -18
- package/src/en-US.js +70 -47
- package/src/en-ZA.d.ts +17 -11
- package/src/en-ZA.js +56 -41
- package/src/es-ES.d.ts +53 -21
- package/src/es-ES.js +104 -56
- package/src/es-MX.d.ts +53 -21
- package/src/es-MX.js +104 -56
- package/src/es-US.d.ts +53 -21
- package/src/es-US.js +92 -51
- package/src/fa-IR.d.ts +3 -5
- package/src/fa-IR.js +28 -13
- package/src/fi-FI.d.ts +3 -6
- package/src/fi-FI.js +47 -29
- package/src/fil-PH.d.ts +3 -5
- package/src/fil-PH.js +61 -28
- package/src/fr-BE.d.ts +31 -15
- package/src/fr-BE.js +128 -57
- package/src/fr-FR.d.ts +31 -16
- package/src/fr-FR.js +97 -60
- package/src/gu-IN.d.ts +3 -5
- package/src/gu-IN.js +31 -16
- package/src/ha-NG.d.ts +3 -5
- package/src/ha-NG.js +55 -27
- package/src/hbo-IL.d.ts +26 -12
- package/src/hbo-IL.js +92 -51
- package/src/he-IL.d.ts +17 -10
- package/src/he-IL.js +92 -50
- package/src/hi-IN.d.ts +3 -5
- package/src/hi-IN.js +30 -17
- package/src/hr-HR.d.ts +21 -10
- package/src/hr-HR.js +89 -33
- package/src/hu-HU.d.ts +3 -5
- package/src/hu-HU.js +57 -23
- package/src/id-ID.d.ts +3 -5
- package/src/id-ID.js +56 -23
- package/src/it-IT.d.ts +17 -11
- package/src/it-IT.js +74 -43
- package/src/ja-JP.d.ts +3 -6
- package/src/ja-JP.js +39 -26
- package/src/ka-GE.d.ts +3 -6
- package/src/ka-GE.js +38 -26
- package/src/kn-IN.d.ts +3 -5
- package/src/kn-IN.js +31 -16
- package/src/ko-KR.d.ts +3 -6
- package/src/ko-KR.js +34 -26
- package/src/lt-LT.d.ts +21 -11
- package/src/lt-LT.js +64 -42
- package/src/lv-LV.d.ts +21 -11
- package/src/lv-LV.js +79 -51
- package/src/mr-IN.d.ts +3 -5
- package/src/mr-IN.js +31 -16
- package/src/ms-MY.d.ts +3 -5
- package/src/ms-MY.js +58 -24
- package/src/nb-NO.d.ts +3 -6
- package/src/nb-NO.js +54 -34
- package/src/nl-NL.d.ts +41 -20
- package/src/nl-NL.js +111 -69
- package/src/pa-IN.d.ts +3 -5
- package/src/pa-IN.js +32 -16
- package/src/pl-PL.d.ts +21 -11
- package/src/pl-PL.js +69 -45
- package/src/pt-BR.d.ts +42 -0
- package/src/pt-BR.js +574 -0
- package/src/pt-PT.d.ts +17 -11
- package/src/pt-PT.js +80 -48
- package/src/ro-RO.d.ts +21 -11
- package/src/ro-RO.js +77 -39
- package/src/ru-RU.d.ts +35 -15
- package/src/ru-RU.js +100 -38
- package/src/sr-Cyrl-RS.d.ts +35 -15
- package/src/sr-Cyrl-RS.js +100 -38
- package/src/sr-Latn-RS.d.ts +35 -15
- package/src/sr-Latn-RS.js +100 -38
- package/src/sv-SE.d.ts +3 -6
- package/src/sv-SE.js +53 -34
- package/src/sw-KE.d.ts +3 -5
- package/src/sw-KE.js +50 -20
- package/src/ta-IN.d.ts +3 -5
- package/src/ta-IN.js +29 -17
- package/src/te-IN.d.ts +3 -5
- package/src/te-IN.js +31 -16
- package/src/th-TH.d.ts +3 -5
- package/src/th-TH.js +42 -19
- package/src/tr-TR.d.ts +17 -11
- package/src/tr-TR.js +63 -37
- package/src/uk-UA.d.ts +21 -10
- package/src/uk-UA.js +89 -33
- package/src/ur-PK.d.ts +3 -5
- package/src/ur-PK.js +32 -16
- package/src/utils/check-max.d.ts +26 -0
- package/src/utils/check-max.js +33 -0
- package/src/utils/expand-scientific.d.ts +0 -4
- package/src/utils/expand-scientific.js +7 -9
- package/src/utils/is-plain-object.d.ts +3 -4
- package/src/utils/is-plain-object.js +3 -4
- package/src/utils/parse-cardinal.d.ts +1 -2
- package/src/utils/parse-cardinal.js +12 -9
- package/src/utils/parse-currency.d.ts +1 -2
- package/src/utils/parse-currency.js +9 -11
- package/src/utils/parse-ordinal.d.ts +0 -1
- package/src/utils/parse-ordinal.js +9 -10
- package/src/utils/resolve-options.d.ts +17 -0
- package/src/utils/resolve-options.js +56 -0
- package/src/utils/scale.d.ts +49 -0
- package/src/utils/scale.js +65 -0
- package/src/vi-VN.d.ts +3 -6
- package/src/vi-VN.js +41 -28
- package/src/yo-NG.d.ts +3 -5
- package/src/yo-NG.js +49 -33
- package/src/zh-Hans-CN.d.ts +45 -20
- package/src/zh-Hans-CN.js +84 -31
- package/src/zh-Hant-TW.d.ts +45 -20
- package/src/zh-Hant-TW.js +85 -34
- package/src/utils/validate-options.d.ts +0 -8
- package/src/utils/validate-options.js +0 -16
package/dist/en-NZ.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-NZ
|
|
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
|
|
1
|
+
/*! n2words/en-NZ v5.1.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,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={enNZ: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={enNZ: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+=" "+(1n===i?"dollar":"dollars")),u>0n&&(i>0n&&(f+=l?" and ":" "),f+=E(u),f+=" "+(1n===u?"cent":"cents")),f}},e.enNZ=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/en-PH.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-PH
|
|
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
|
|
1
|
+
/*! n2words/en-PH v5.1.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)}}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+=" "+(1n===s?"peso":"pesos")),u>0n&&(s>0n&&(c+=l?" and ":" "),c+=I(u),c+=" "+(1n===u?"centavo":"centavos")),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-PH.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-PH
|
|
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
|
|
1
|
+
/*! n2words/en-PH v5.1.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,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",p="zero",b="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 p;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={enPH: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={enPH: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=b+" "),(i>0n||0n===u)&&(f+=E(i),f+=" "+(1n===i?"peso":"pesos")),u>0n&&(i>0n&&(f+=l?" and ":" "),f+=E(u),f+=" "+(1n===u?"centavo":"centavos")),f}},e.enPH=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=b+" "),f+=E(u),l&&(f+=" point "+function(e){let n="",t=0;for(;t<e.length&&"0"===e[t];)n&&(n+=" "),n+=p,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/en-PK.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-PK
|
|
2
|
-
function e(e){let[n
|
|
1
|
+
/*! n2words/en-PK v5.1.0 | MIT License | github.com/forzagreen/n2words */
|
|
2
|
+
function e(e){let[t,n]=e.toLowerCase().split("e");const r=parseInt(n,10);let i="";"-"===t[0]&&(i="-",t=t.slice(1));const o=t.indexOf("."),s=-1===o?t:t.slice(0,o)+t.slice(o+1),u=(-1===o?t.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(t){const r=t.toString();return n(r)?e(r):r}function n(e){return e.includes("e")||e.includes("E")}function r(e){const t="-"===e[0];t&&(e=e.slice(1));const n=e.indexOf(".");if(-1===n)return{isNegative:t,integerPart:BigInt(e)};const r=e.slice(0,n)||"0",i=e.slice(n+1);return{isNegative:t,integerPart:BigInt(r),decimalPart:i}}function i(t){let r=t.trim();if(0===r.length||Number.isNaN(Number(r)))throw new RangeError(`Invalid currency format: "${t}"`);n(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,t,n){if(null===t)return;if(e<t&&!(n&&BigInt(n)>=t))return;const r=t.toString().length-1,i=t===10n**BigInt(r)?`10^${r} - 1`:""+(t-1n);throw new RangeError(`Number too large to convert: the largest supported value is ${i}`)}function s(e){return 10n**BigInt(3+2*(e-1))}const u=["","one","two","three","four","five","six","seven","eight","nine"],f=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],a=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],c=["thousand","lakh","crore","arab","kharab","neel","padma","shankh"],h=s(c.length+1),l=s(c.length+1),g=s(c.length+1),d="hundred",p="zero",w="minus",b=["","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 t=e%10,n=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===n?i=f[t]:n>=2?i=t>0?a[n]+"-"+u[t]:a[n]:t>0&&(i=u[t]),r>0?(y.word=i?u[r]+" "+d+" and "+i:u[r]+" "+d,y.hasHundred=!0):(y.word=i,y.hasHundred=!1),y}function I(e){if(0===e)return"";const t=e%10,n=Math.trunc(e/10);return 1===n?f[t]:n>=2?t>0?a[n]+"-"+u[t]:a[n]:u[t]}function E(e){if(0n===e)return p;if(e<1000n)return N(Number(e)).word;const t=[];t.push(Number(e%1000n));let n=e/1000n;for(;n>0n;)t.push(Number(n%100n)),n/=100n;const r=[];for(let e=t.length-1;e>=0;e--){const n=t[e];if(0!==n)if(0===e){const{word:e,hasHundred:t}=N(n);r.length>0&&!t&&r.push("and"),r.push(e)}else r.push(I(n)),c[e-1]&&r.push(c[e-1])}return r.join(" ")}function O(i){const{isNegative:s,integerPart:u,decimalPart:f}=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(t(i))}if("string"==typeof i)return r(function(t){const r=t.trim();if(0===r.length||Number.isNaN(Number(r)))throw new RangeError(`Invalid number format: "${t}"`);return n(r)?e(r):r}(i));throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${o}`)}(i);o(u,h,f);let a="";return s&&(a=w+" "),a+=E(u),f&&(a+=" point "+function(e){let t="",n=0;for(;n<e.length&&"0"===e[n];)t&&(t+=" "),t+=p,n++;const r=e.slice(n);return r&&(t&&(t+=" "),t+=E(BigInt(r))),t}(f)),a}function R(e){const t=e%10,n=Math.trunc(e/10)%10,r=Math.trunc(e/100);let i="";return 1===n?i=m[t]:n>=2?i=t>0?a[n]+"-"+b[t]:v[n]:t>0&&(i=b[t]),r>0?i?u[r]+" "+d+" "+i:u[r]+" hundredth":i}function B(t){const r=function(t){const r=typeof t;if("bigint"==typeof t){if(t<=0n)throw new RangeError("Ordinals must be positive integers");return t}if("number"==typeof t){if(!Number.isFinite(t))throw new RangeError("Ordinals must be finite numbers");if(!Number.isInteger(t))throw new RangeError("Ordinals must be whole numbers");if(t<=0)throw new RangeError("Ordinals must be positive integers");return BigInt(t)}if("string"==typeof t)return function(t){const r=t.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(n(r)){const t=e(r);if(t.includes("."))throw new RangeError("Ordinals must be whole numbers");const n=BigInt(t);if(n<=0n)throw new RangeError("Ordinals must be positive integers");return n}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: "${t}"`,{cause:e})}}(t);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${r}`)}(t);return o(r,l),function(e){if(e<1000n)return R(Number(e));const t=[];t.push(Number(e%1000n));let n=e/1000n;for(;n>0n;)t.push(Number(n%100n)),n/=100n;let r=0;for(let e=0;e<t.length;e++)if(0!==t[e]){r=e;break}const i=[];for(let e=t.length-1;e>=0;e--){const n=t[e];0!==n&&(e===r?0===e?i.push(R(n)):(i.push(I(n)),i.push(c[e-1]+"th")):0===e?i.push(N(n).word):(i.push(I(n)),i.push(c[e-1])))}return i.join(" ")}(r)}const x={and:!0};function $(e,n){const{isNegative:r,dollars:s,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}:i(t(e))}if("string"==typeof e)return i(e);throw new TypeError(`Invalid value type: expected number, string, or bigint, received ${n}`)}(e);o(s,g);const{and:f}=function(e,t){const n={...t};if(void 0===e)return n;if(!function(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}(e))throw new TypeError("Invalid options: expected plain object or undefined, got "+typeof e);const r=Object.keys(t);for(const[i,o]of Object.entries(e)){if(!Object.hasOwn(t,i))throw new TypeError(`Unknown option "${i}" — expected one of: ${r.join(", ")}`);if(void 0!==o){if(typeof o!=typeof n[i])throw new TypeError(`Option "${i}" must be a ${typeof n[i]}, got ${typeof o}`);n[i]=o}}return n}(n,x);let a="";return r&&(a=w+" "),(s>0n||0n===u)&&(a+=E(s),a+=" "+(1n===s?"rupee":"rupees")),u>0n&&(s>0n&&(a+=f?" and ":" "),a+=E(u),a+=" "+(1n===u?"paisa":"paise")),a}export{h as cardinalMax,x as currencyDefaults,g as currencyMax,l as ordinalMax,O as toCardinal,$ as toCurrency,B as toOrdinal};
|
package/dist/en-PK.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-PK
|
|
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
|
|
1
|
+
/*! n2words/en-PK v5.1.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,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+2*(e-1))}const f=["","one","two","three","four","five","six","seven","eight","nine"],a=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],c=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],h=["thousand","lakh","crore","arab","kharab","neel","padma","shankh"],l=u(h.length+1),g=u(h.length+1),d=u(h.length+1),p="hundred",w="zero",b="minus",m=["","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth"],y=["tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth"],v=["","","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=a[n]:t>=2?i=n>0?c[t]+"-"+f[n]:c[t]:n>0&&(i=f[n]),r>0?(N.word=i?f[r]+" "+p+" and "+i:f[r]+" "+p,N.hasHundred=!0):(N.word=i,N.hasHundred=!1),N}function E(e){if(0===e)return"";const n=e%10,t=Math.trunc(e/10);return 1===t?a[n]:t>=2?n>0?c[t]+"-"+f[n]:c[t]:f[n]}function O(e){if(0n===e)return w;if(e<1000n)return I(Number(e)).word;const n=[];n.push(Number(e%1000n));let t=e/1000n;for(;t>0n;)n.push(Number(t%100n)),t/=100n;const r=[];for(let e=n.length-1;e>=0;e--){const t=n[e];if(0!==t)if(0===e){const{word:e,hasHundred:n}=I(t);r.length>0&&!n&&r.push("and"),r.push(e)}else r.push(E(t)),h[e-1]&&r.push(h[e-1])}return r.join(" ")}function x(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?c[t]+"-"+m[n]:v[t]:n>0&&(i=m[n]),r>0?i?f[r]+" "+p+" "+i:f[r]+" hundredth":i}const R={and:!0},B={enPK: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 x(Number(e));const n=[];n.push(Number(e%1000n));let t=e/1000n;for(;t>0n;)n.push(Number(t%100n)),t/=100n;let r=0;for(let e=0;e<n.length;e++)if(0!==n[e]){r=e;break}const i=[];for(let e=n.length-1;e>=0;e--){const t=n[e];0!==t&&(e===r?0===e?i.push(x(t)):(i.push(E(t)),i.push(h[e-1]+"th")):0===e?i.push(I(t).word):(i.push(E(t)),i.push(h[e-1])))}return i.join(" ")}(t)}};e.currency={enPK: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,d);const{and:f}=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,R);let a="";return r&&(a=b+" "),(i>0n||0n===u)&&(a+=O(i),a+=" "+(1n===i?"rupee":"rupees")),u>0n&&(i>0n&&(a+=f?" and ":" "),a+=O(u),a+=" "+(1n===u?"paisa":"paise")),a}},e.enPK=function(e){const{isNegative:o,integerPart:u,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)}: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,l,f);let a="";return o&&(a=b+" "),a+=O(u),f&&(a+=" 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+=O(BigInt(r))),n}(f)),a},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||{});
|
package/dist/en-SG.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-SG
|
|
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
|
|
1
|
+
/*! n2words/en-SG v5.1.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)}}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+=" "+(1n===s?"dollar":"dollars")),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-SG.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-SG
|
|
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
|
|
1
|
+
/*! n2words/en-SG v5.1.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,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={enSG: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={enSG: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+=" "+(1n===i?"dollar":"dollars")),u>0n&&(i>0n&&(f+=l?" and ":" "),f+=E(u),f+=" "+(1n===u?"cent":"cents")),f}},e.enSG=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/en-US.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-US
|
|
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){if(
|
|
1
|
+
/*! n2words/en-US v5.1.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)}}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))}function u(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 l=["","one","two","three","four","five","six","seven","eight","nine"],c=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],f=["","","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=s(a.length),g=s(a.length),h=s(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,n){if(0===e)return N.word="",N.hasHundred=!1,N;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?f[r]+"-"+l[t]:f[r]:t>0&&(o=l[t]),i>0?(N.word=o?l[i]+" "+w+(n?" and ":" ")+o:l[i]+" "+w,N.hasHundred=!0):(N.word=o,N.hasHundred=!1),N}function E(e,n,t){if(0n===e)return b;if(e<1000n)return I(Number(e),t).word;if(n&&e>=1100n&&e<=9999n){const n=Number(e),r=Math.trunc(n/100),i=n%100,{word:o}=I(r,t);let s=o+" "+w;if(i>0){const{word:e}=I(i,t);t&&(s+=" and"),s+=" "+e}return s}if(e<1000000n){const n=Number(e/1000n),r=Number(e%1000n),{word:i}=I(n,t);let o=i+" "+a[0];if(r>0){const{word:e,hasHundred:n}=I(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}=I(r,n);n&&o&&e===i&&s&&!l&&(o+=" and"),o&&(o+=" "),o+=u,e>0?(o+=" "+a[e-1],s=!0):s=!1}return o}(e,t)}const O={hundredPairing:!1,and:!1};function x(i,s){const{isNegative:l,integerPart:c,decimalPart:f}=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(c,d,f);const{hundredPairing:a,and:g}=u(s,O);let h="";return l&&(h=p+" "),h+=E(c,a,g),f&&(h+=" point "+function(e,n){let t="",r=0;for(;r<e.length&&"0"===e[r];)t&&(t+=" "),t+=b,r++;const i=e.slice(r);return i&&(t&&(t+=" "),t+=E(BigInt(i),!1,n)),t}(f,g)),h}function R(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?f[t]+"-"+m[n]:y[t]:n>0&&(i=m[n]),r>0?i?l[r]+" "+w+" "+i:l[r]+" hundredth":i}function B(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 R(Number(e));if(e<1000000n){const n=Number(e/1000n),t=Number(e%1000n);if(0===t)return I(n,!1).word+" "+a[0]+"th";const{word:r}=I(n,!1);return r+" "+a[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):I(t,!1).word+" "+a[e-1]+"th":(i+=I(t,!1).word,e>0&&(i+=" "+a[e-1])))}return i}(e)}(r)}const $={and:!0};function P(e,t){const{isNegative:r,dollars:s,cents:l}=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,h);const{and:c}=u(t,$);let f="";return r&&(f=p+" "),(s>0n||0n===l)&&(f+=E(s,!1,!1),f+=" "+(1n===s?"dollar":"dollars")),l>0n&&(s>0n&&(f+=c?" and ":" "),f+=E(l,!1,!1),f+=" "+(1n===l?"cent":"cents")),f}export{O as cardinalDefaults,d as cardinalMax,$ as currencyDefaults,h as currencyMax,g as ordinalMax,x as toCardinal,P as toCurrency,B as toOrdinal};
|
package/dist/en-US.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! n2words/en-US
|
|
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(
|
|
1
|
+
/*! n2words/en-US v5.1.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,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
|
|
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
|
|
1
|
+
/*! n2words/en-ZA v5.1.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)}}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};
|