UNPKG

n2words

Version:

n2words converts a numerical number into a written one, supports 28 languages and has zero dependencies.

2 lines 15.9 kB
!function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.n2words=t():r.n2words=t()}(this,()=>(()=>{"use strict";var r={34:(r,t,e)=>{var n=e(4901);r.exports=function(r){return"object"==typeof r?null!==r:n(r)}},283:(r,t,e)=>{var n=e(9504),o=e(9039),i=e(4901),a=e(9297),u=e(3724),s=e(350).CONFIGURABLE,c=e(3706),p=e(1181),f=p.enforce,l=p.get,v=String,h=Object.defineProperty,b=n("".slice),y=n("".replace),d=n([].join),g=u&&!o(function(){return 8!==h(function(){},"length",{value:8}).length}),m=String(String).split("String"),x=r.exports=function(r,t,e){"Symbol("===b(v(t),0,7)&&(t="["+y(v(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),e&&e.getter&&(t="get "+t),e&&e.setter&&(t="set "+t),(!a(r,"name")||s&&r.name!==t)&&(u?h(r,"name",{value:t,configurable:!0}):r.name=t),g&&e&&a(e,"arity")&&r.length!==e.arity&&h(r,"length",{value:e.arity});try{e&&a(e,"constructor")&&e.constructor?u&&h(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch(r){}var n=f(r);return a(n,"source")||(n.source=d(m,"string"==typeof t?t:"")),r};Function.prototype.toString=x(function(){return i(this)&&l(this).source||c(this)},"toString")},350:(r,t,e)=>{var n=e(3724),o=e(9297),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,u=o(i,"name"),s=u&&"something"===function(){}.name,c=u&&(!n||n&&a(i,"name").configurable);r.exports={EXISTS:u,PROPER:s,CONFIGURABLE:c}},421:r=>{r.exports={}},616:(r,t,e)=>{var n=e(9039);r.exports=!n(function(){var r=function(){}.bind();return"function"!=typeof r||r.hasOwnProperty("prototype")})},741:r=>{var t=Math.ceil,e=Math.floor;r.exports=Math.trunc||function(r){var n=+r;return(n>0?e:t)(n)}},757:(r,t,e)=>{var n=e(7751),o=e(4901),i=e(1625),a=e(7040),u=Object;r.exports=a?function(r){return"symbol"==typeof r}:function(r){var t=n("Symbol");return o(t)&&i(t.prototype,u(r))}},1181:(r,t,e)=>{var n,o,i,a=e(8622),u=e(4576),s=e(34),c=e(6699),p=e(9297),f=e(7629),l=e(6119),v=e(421),h="Object already initialized",b=u.TypeError,y=u.WeakMap;if(a||f.state){var d=f.state||(f.state=new y);d.get=d.get,d.has=d.has,d.set=d.set,n=function(r,t){if(d.has(r))throw new b(h);return t.facade=r,d.set(r,t),t},o=function(r){return d.get(r)||{}},i=function(r){return d.has(r)}}else{var g=l("state");v[g]=!0,n=function(r,t){if(p(r,g))throw new b(h);return t.facade=r,c(r,g,t),t},o=function(r){return p(r,g)?r[g]:{}},i=function(r){return p(r,g)}}r.exports={set:n,get:o,has:i,enforce:function(r){return i(r)?o(r):n(r,{})},getterFor:function(r){return function(t){var e;if(!s(t)||(e=o(t)).type!==r)throw new b("Incompatible receiver, "+r+" required");return e}}}},1291:(r,t,e)=>{var n=e(741);r.exports=function(r){var t=+r;return t!=t||0===t?0:n(t)}},1625:(r,t,e)=>{var n=e(9504);r.exports=n({}.isPrototypeOf)},1828:(r,t,e)=>{var n=e(9504),o=e(9297),i=e(5397),a=e(9617).indexOf,u=e(421),s=n([].push);r.exports=function(r,t){var e,n=i(r),c=0,p=[];for(e in n)!o(u,e)&&o(n,e)&&s(p,e);for(;t.length>c;)o(n,e=t[c++])&&(~a(p,e)||s(p,e));return p}},2195:(r,t,e)=>{var n=e(9504),o=n({}.toString),i=n("".slice);r.exports=function(r){return i(o(r),8,-1)}},2777:(r,t,e)=>{var n=e(9565),o=e(34),i=e(757),a=e(5966),u=e(4270),s=e(8227),c=TypeError,p=s("toPrimitive");r.exports=function(r,t){if(!o(r)||i(r))return r;var e,s=a(r,p);if(s){if(void 0===t&&(t="default"),e=n(s,r,t),!o(e)||i(e))return e;throw new c("Can't convert object to primitive value")}return void 0===t&&(t="number"),u(r,t)}},2796:(r,t,e)=>{var n=e(9039),o=e(4901),i=/#|\.prototype\./,a=function(r,t){var e=s[u(r)];return e===p||e!==c&&(o(t)?n(t):!!t)},u=a.normalize=function(r){return String(r).replace(i,".").toLowerCase()},s=a.data={},c=a.NATIVE="N",p=a.POLYFILL="P";r.exports=a},2839:(r,t,e)=>{var n=e(4576).navigator,o=n&&n.userAgent;r.exports=o?String(o):""},3392:(r,t,e)=>{var n=e(9504),o=0,i=Math.random(),a=n(1.1.toString);r.exports=function(r){return"Symbol("+(void 0===r?"":r)+")_"+a(++o+i,36)}},3706:(r,t,e)=>{var n=e(9504),o=e(4901),i=e(7629),a=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(r){return a(r)}),r.exports=i.inspectSource},3717:(r,t)=>{t.f=Object.getOwnPropertySymbols},3724:(r,t,e)=>{var n=e(9039);r.exports=!n(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})},4055:(r,t,e)=>{var n=e(4576),o=e(34),i=n.document,a=o(i)&&o(i.createElement);r.exports=function(r){return a?i.createElement(r):{}}},4114:(r,t,e)=>{var n=e(6518),o=e(8981),i=e(6198),a=e(4527),u=e(6837);n({target:"Array",proto:!0,arity:1,forced:e(9039)(function(){return 4294967297!==[].push.call({length:4294967296},1)})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(r){return r instanceof TypeError}}()},{push:function(r){var t=o(this),e=i(t),n=arguments.length;u(e+n);for(var s=0;s<n;s++)t[e]=arguments[s],e++;return a(t,e),e}})},4117:r=>{r.exports=function(r){return null==r}},4270:(r,t,e)=>{var n=e(9565),o=e(4901),i=e(34),a=TypeError;r.exports=function(r,t){var e,u;if("string"===t&&o(e=r.toString)&&!i(u=n(e,r)))return u;if(o(e=r.valueOf)&&!i(u=n(e,r)))return u;if("string"!==t&&o(e=r.toString)&&!i(u=n(e,r)))return u;throw new a("Can't convert object to primitive value")}},4376:(r,t,e)=>{var n=e(2195);r.exports=Array.isArray||function(r){return"Array"===n(r)}},4495:(r,t,e)=>{var n=e(9519),o=e(9039),i=e(4576).String;r.exports=!!Object.getOwnPropertySymbols&&!o(function(){var r=Symbol("symbol detection");return!i(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&n&&n<41})},4527:(r,t,e)=>{var n=e(3724),o=e(4376),i=TypeError,a=Object.getOwnPropertyDescriptor,u=n&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(r){return r instanceof TypeError}}();r.exports=u?function(r,t){if(o(r)&&!a(r,"length").writable)throw new i("Cannot set read only .length");return r.length=t}:function(r,t){return r.length=t}},4576:function(r){var t=function(r){return r&&r.Math===Math&&r};r.exports=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof global&&global)||t("object"==typeof this&&this)||function(){return this}()||Function("return this")()},4901:r=>{var t="object"==typeof document&&document.all;r.exports=void 0===t&&void 0!==t?function(r){return"function"==typeof r||r===t}:function(r){return"function"==typeof r}},4913:(r,t,e)=>{var n=e(3724),o=e(5917),i=e(8686),a=e(8551),u=e(6969),s=TypeError,c=Object.defineProperty,p=Object.getOwnPropertyDescriptor,f="enumerable",l="configurable",v="writable";t.f=n?i?function(r,t,e){if(a(r),t=u(t),a(e),"function"==typeof r&&"prototype"===t&&"value"in e&&v in e&&!e[v]){var n=p(r,t);n&&n[v]&&(r[t]=e.value,e={configurable:l in e?e[l]:n[l],enumerable:f in e?e[f]:n[f],writable:!1})}return c(r,t,e)}:c:function(r,t,e){if(a(r),t=u(t),a(e),o)try{return c(r,t,e)}catch(r){}if("get"in e||"set"in e)throw new s("Accessors not supported");return"value"in e&&(r[t]=e.value),r}},5031:(r,t,e)=>{var n=e(7751),o=e(9504),i=e(8480),a=e(3717),u=e(8551),s=o([].concat);r.exports=n("Reflect","ownKeys")||function(r){var t=i.f(u(r)),e=a.f;return e?s(t,e(r)):t}},5397:(r,t,e)=>{var n=e(7055),o=e(7750);r.exports=function(r){return n(o(r))}},5610:(r,t,e)=>{var n=e(1291),o=Math.max,i=Math.min;r.exports=function(r,t){var e=n(r);return e<0?o(e+t,0):i(e,t)}},5745:(r,t,e)=>{var n=e(7629);r.exports=function(r,t){return n[r]||(n[r]=t||{})}},5917:(r,t,e)=>{var n=e(3724),o=e(9039),i=e(4055);r.exports=!n&&!o(function(){return 7!==Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a})},5966:(r,t,e)=>{var n=e(9306),o=e(4117);r.exports=function(r,t){var e=r[t];return o(e)?void 0:n(e)}},6119:(r,t,e)=>{var n=e(5745),o=e(3392),i=n("keys");r.exports=function(r){return i[r]||(i[r]=o(r))}},6198:(r,t,e)=>{var n=e(8014);r.exports=function(r){return n(r.length)}},6298:(r,t,e)=>{e.d(t,{A:()=>n}),e(4114);const n=class{#r;#t;#e;#n;#o;constructor(r){r=Object.assign({negativeWord:"",separatorWord:"",zero:"",spaceSeparator:" "},r),this.#r=r.negativeWord,this.#t=r.separatorWord,this.#e=r.zero,this.#n=r.spaceSeparator}get negativeWord(){return this.#r}get separatorWord(){return this.#t}get zero(){return this.#e}get spaceSeparator(){return this.#n}get wholeNumber(){return this.#o}decimalToCardinal(r){const t=[],e=[...r];let n=0;for(;n<e.length&&"0"===e[n];)t.push(this.zero),n++;return n===e.length?t:[...t,this.toCardinal(BigInt(r))]}floatToCardinal(r){if("number"==typeof r){if(Number.isNaN(r))throw new TypeError("NaN is not an accepted number.");r=r.toString()}else if("string"==typeof r){if(0===(r=r.trim()).length||Number.isNaN(Number(r)))throw new Error('"'+r+'" is not a valid number.')}else if("bigint"!=typeof r)throw new TypeError("Invalid variable type: "+typeof r);let t,e,n=[];if(r<0&&n.push(this.negativeWord),"bigint"==typeof r)t=r;else{const n=r.split(".");t=BigInt(n[0]),e=n[1]}return t<0&&(t=-t),this.#o=t,n=[...n,this.toCardinal(t)],e&&(n.push(this.separatorWord),n=[...n,...this.decimalToCardinal(e)]),n.join(this.spaceSeparator)}}},6395:r=>{r.exports=!1},6518:(r,t,e)=>{var n=e(4576),o=e(7347).f,i=e(6699),a=e(6840),u=e(9433),s=e(7740),c=e(2796);r.exports=function(r,t){var e,p,f,l,v,h=r.target,b=r.global,y=r.stat;if(e=b?n:y?n[h]||u(h,{}):n[h]&&n[h].prototype)for(p in t){if(l=t[p],f=r.dontCallGetSet?(v=o(e,p))&&v.value:e[p],!c(b?p:h+(y?".":"#")+p,r.forced)&&void 0!==f){if(typeof l==typeof f)continue;s(l,f)}(r.sham||f&&f.sham)&&i(l,"sham",!0),a(e,p,l,r)}}},6699:(r,t,e)=>{var n=e(3724),o=e(4913),i=e(6980);r.exports=n?function(r,t,e){return o.f(r,t,i(1,e))}:function(r,t,e){return r[t]=e,r}},6823:r=>{var t=String;r.exports=function(r){try{return t(r)}catch(r){return"Object"}}},6837:r=>{var t=TypeError;r.exports=function(r){if(r>9007199254740991)throw t("Maximum allowed index exceeded");return r}},6840:(r,t,e)=>{var n=e(4901),o=e(4913),i=e(283),a=e(9433);r.exports=function(r,t,e,u){u||(u={});var s=u.enumerable,c=void 0!==u.name?u.name:t;if(n(e)&&i(e,c,u),u.global)s?r[t]=e:a(t,e);else{try{u.unsafe?r[t]&&(s=!0):delete r[t]}catch(r){}s?r[t]=e:o.f(r,t,{value:e,enumerable:!1,configurable:!u.nonConfigurable,writable:!u.nonWritable})}return r}},6969:(r,t,e)=>{var n=e(2777),o=e(757);r.exports=function(r){var t=n(r,"string");return o(t)?t:t+""}},6980:r=>{r.exports=function(r,t){return{enumerable:!(1&r),configurable:!(2&r),writable:!(4&r),value:t}}},7040:(r,t,e)=>{var n=e(4495);r.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},7055:(r,t,e)=>{var n=e(9504),o=e(9039),i=e(2195),a=Object,u=n("".split);r.exports=o(function(){return!a("z").propertyIsEnumerable(0)})?function(r){return"String"===i(r)?u(r,""):a(r)}:a},7347:(r,t,e)=>{var n=e(3724),o=e(9565),i=e(8773),a=e(6980),u=e(5397),s=e(6969),c=e(9297),p=e(5917),f=Object.getOwnPropertyDescriptor;t.f=n?f:function(r,t){if(r=u(r),t=s(t),p)try{return f(r,t)}catch(r){}if(c(r,t))return a(!o(i.f,r,t),r[t])}},7629:(r,t,e)=>{var n=e(6395),o=e(4576),i=e(9433),a="__core-js_shared__",u=r.exports=o[a]||i(a,{});(u.versions||(u.versions=[])).push({version:"3.45.0",mode:n?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.45.0/LICENSE",source:"https://github.com/zloirock/core-js"})},7740:(r,t,e)=>{var n=e(9297),o=e(5031),i=e(7347),a=e(4913);r.exports=function(r,t,e){for(var u=o(t),s=a.f,c=i.f,p=0;p<u.length;p++){var f=u[p];n(r,f)||e&&n(e,f)||s(r,f,c(t,f))}}},7750:(r,t,e)=>{var n=e(4117),o=TypeError;r.exports=function(r){if(n(r))throw new o("Can't call method on "+r);return r}},7751:(r,t,e)=>{var n=e(4576),o=e(4901);r.exports=function(r,t){return arguments.length<2?(e=n[r],o(e)?e:void 0):n[r]&&n[r][t];var e}},8014:(r,t,e)=>{var n=e(1291),o=Math.min;r.exports=function(r){var t=n(r);return t>0?o(t,9007199254740991):0}},8227:(r,t,e)=>{var n=e(4576),o=e(5745),i=e(9297),a=e(3392),u=e(4495),s=e(7040),c=n.Symbol,p=o("wks"),f=s?c.for||c:c&&c.withoutSetter||a;r.exports=function(r){return i(p,r)||(p[r]=u&&i(c,r)?c[r]:f("Symbol."+r)),p[r]}},8480:(r,t,e)=>{var n=e(1828),o=e(8727).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(r){return n(r,o)}},8551:(r,t,e)=>{var n=e(34),o=String,i=TypeError;r.exports=function(r){if(n(r))return r;throw new i(o(r)+" is not an object")}},8622:(r,t,e)=>{var n=e(4576),o=e(4901),i=n.WeakMap;r.exports=o(i)&&/native code/.test(String(i))},8686:(r,t,e)=>{var n=e(3724),o=e(9039);r.exports=n&&o(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})},8727:r=>{r.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},8773:(r,t)=>{var e={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,o=n&&!e.call({1:2},1);t.f=o?function(r){var t=n(this,r);return!!t&&t.enumerable}:e},8981:(r,t,e)=>{var n=e(7750),o=Object;r.exports=function(r){return o(n(r))}},9039:r=>{r.exports=function(r){try{return!!r()}catch(r){return!0}}},9297:(r,t,e)=>{var n=e(9504),o=e(8981),i=n({}.hasOwnProperty);r.exports=Object.hasOwn||function(r,t){return i(o(r),t)}},9306:(r,t,e)=>{var n=e(4901),o=e(6823),i=TypeError;r.exports=function(r){if(n(r))return r;throw new i(o(r)+" is not a function")}},9433:(r,t,e)=>{var n=e(4576),o=Object.defineProperty;r.exports=function(r,t){try{o(n,r,{value:t,configurable:!0,writable:!0})}catch(e){n[r]=t}return t}},9504:(r,t,e)=>{var n=e(616),o=Function.prototype,i=o.call,a=n&&o.bind.bind(i,i);r.exports=n?a:function(r){return function(){return i.apply(r,arguments)}}},9519:(r,t,e)=>{var n,o,i=e(4576),a=e(2839),u=i.process,s=i.Deno,c=u&&u.versions||s&&s.version,p=c&&c.v8;p&&(o=(n=p.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!o&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(o=+n[1]),r.exports=o},9565:(r,t,e)=>{var n=e(616),o=Function.prototype.call;r.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},9617:(r,t,e)=>{var n=e(5397),o=e(5610),i=e(6198),a=function(r){return function(t,e,a){var u=n(t),s=i(u);if(0===s)return!r&&-1;var c,p=o(a,s);if(r&&e!=e){for(;s>p;)if((c=u[p++])!=c)return!0}else for(;s>p;p++)if((r||p in u)&&u[p]===e)return r||p||0;return!r&&-1}};r.exports={includes:a(!0),indexOf:a(!1)}}},t={};function e(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return r[n].call(i.exports,i,i.exports,e),i.exports}e.d=(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},e.o=(r,t)=>Object.prototype.hasOwnProperty.call(r,t);var n={};e.d(n,{default:()=>a});var o=e(6298);class i extends o.A{namedNumbers={0:"صفر",1:"یک",2:"دو",3:"سه",4:"چهار",5:"پنج",6:"شش",7:"هفت",8:"هشت",9:"نه",10:"ده",11:"یازده",12:"دوازده",13:"سیزده",14:"چهارده",15:"پانزده",16:"شانزده",17:"هفده",18:"هجده",19:"نوزده",20:"بیست",30:"سی",40:"چهل",50:"پنجاه",60:"شصت",70:"هفتاد",80:"هشتاد",90:"نود",100:"صد",200:"دویست",300:"سيصد",400:"چهار صد",500:"پانصد",600:"ششصد",700:"هفتصد",800:"هشتصد",900:"نهصد",1e3:"هزار",1e6:"میلیون"};constructor(r){super(r=Object.assign({negativeWord:"منفى",separatorWord:"ممیّز",zero:"صفر"},r))}toCardinal(r){if(this.namedNumbers[r])return this.namedNumbers[r];if(r>20n&&r<100n){let t=r%10n,e=r-t;return`${this.namedNumbers[e]} و ${this.namedNumbers[t]}`}if(r>100n&&r<1000n){let t=r/100n*100n,e=this.toCardinal(r-t);return`${this.namedNumbers[t]} و ${e}`}if(r>1000n&&r<1000000n){let t=r/1000n,e=r-1000n*t;return`${(1n==t?"":this.toCardinal(t))+" "+this.namedNumbers[1e3]}${0n==e?"":" "+this.toCardinal(e)}`}if(r>1000000n){let t=r/1000000n,e=r-1000000n*t;return`${this.toCardinal(t)+" "+this.namedNumbers[1e6]}${0n==e?"":" و "+this.toCardinal(e)}`}}}function a(r,t={}){return new i(t).floatToCardinal(r)}return n.default})()); //# sourceMappingURL=fa.js.map