n2words
Version:
n2words converts a numerical number into a written one, supports 28 languages and has zero dependencies.
2 lines • 16.2 kB
JavaScript
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.n2words=r():t.n2words=r()}(this,()=>(()=>{"use strict";var t={34:(t,r,e)=>{var n=e(4901);t.exports=function(t){return"object"==typeof t?null!==t:n(t)}},283:(t,r,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),g=n([].join),m=u&&!o(function(){return 8!==h(function(){},"length",{value:8}).length}),d=String(String).split("String"),x=t.exports=function(t,r,e){"Symbol("===b(v(r),0,7)&&(r="["+y(v(r),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),e&&e.getter&&(r="get "+r),e&&e.setter&&(r="set "+r),(!a(t,"name")||s&&t.name!==r)&&(u?h(t,"name",{value:r,configurable:!0}):t.name=r),m&&e&&a(e,"arity")&&t.length!==e.arity&&h(t,"length",{value:e.arity});try{e&&a(e,"constructor")&&e.constructor?u&&h(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var n=f(t);return a(n,"source")||(n.source=g(d,"string"==typeof r?r:"")),t};Function.prototype.toString=x(function(){return i(this)&&l(this).source||c(this)},"toString")},350:(t,r,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);t.exports={EXISTS:u,PROPER:s,CONFIGURABLE:c}},421:t=>{t.exports={}},616:(t,r,e)=>{var n=e(9039);t.exports=!n(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})},741:t=>{var r=Math.ceil,e=Math.floor;t.exports=Math.trunc||function(t){var n=+t;return(n>0?e:r)(n)}},757:(t,r,e)=>{var n=e(7751),o=e(4901),i=e(1625),a=e(7040),u=Object;t.exports=a?function(t){return"symbol"==typeof t}:function(t){var r=n("Symbol");return o(r)&&i(r.prototype,u(t))}},1181:(t,r,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 g=f.state||(f.state=new y);g.get=g.get,g.has=g.has,g.set=g.set,n=function(t,r){if(g.has(t))throw new b(h);return r.facade=t,g.set(t,r),r},o=function(t){return g.get(t)||{}},i=function(t){return g.has(t)}}else{var m=l("state");v[m]=!0,n=function(t,r){if(p(t,m))throw new b(h);return r.facade=t,c(t,m,r),r},o=function(t){return p(t,m)?t[m]:{}},i=function(t){return p(t,m)}}t.exports={set:n,get:o,has:i,enforce:function(t){return i(t)?o(t):n(t,{})},getterFor:function(t){return function(r){var e;if(!s(r)||(e=o(r)).type!==t)throw new b("Incompatible receiver, "+t+" required");return e}}}},1291:(t,r,e)=>{var n=e(741);t.exports=function(t){var r=+t;return r!=r||0===r?0:n(r)}},1625:(t,r,e)=>{var n=e(9504);t.exports=n({}.isPrototypeOf)},1828:(t,r,e)=>{var n=e(9504),o=e(9297),i=e(5397),a=e(9617).indexOf,u=e(421),s=n([].push);t.exports=function(t,r){var e,n=i(t),c=0,p=[];for(e in n)!o(u,e)&&o(n,e)&&s(p,e);for(;r.length>c;)o(n,e=r[c++])&&(~a(p,e)||s(p,e));return p}},2195:(t,r,e)=>{var n=e(9504),o=n({}.toString),i=n("".slice);t.exports=function(t){return i(o(t),8,-1)}},2777:(t,r,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");t.exports=function(t,r){if(!o(t)||i(t))return t;var e,s=a(t,p);if(s){if(void 0===r&&(r="default"),e=n(s,t,r),!o(e)||i(e))return e;throw new c("Can't convert object to primitive value")}return void 0===r&&(r="number"),u(t,r)}},2796:(t,r,e)=>{var n=e(9039),o=e(4901),i=/#|\.prototype\./,a=function(t,r){var e=s[u(t)];return e===p||e!==c&&(o(r)?n(r):!!r)},u=a.normalize=function(t){return String(t).replace(i,".").toLowerCase()},s=a.data={},c=a.NATIVE="N",p=a.POLYFILL="P";t.exports=a},2839:(t,r,e)=>{var n=e(4576).navigator,o=n&&n.userAgent;t.exports=o?String(o):""},3392:(t,r,e)=>{var n=e(9504),o=0,i=Math.random(),a=n(1.1.toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+a(++o+i,36)}},3706:(t,r,e)=>{var n=e(9504),o=e(4901),i=e(7629),a=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return a(t)}),t.exports=i.inspectSource},3717:(t,r)=>{r.f=Object.getOwnPropertySymbols},3724:(t,r,e)=>{var n=e(9039);t.exports=!n(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})},4055:(t,r,e)=>{var n=e(4576),o=e(34),i=n.document,a=o(i)&&o(i.createElement);t.exports=function(t){return a?i.createElement(t):{}}},4114:(t,r,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(t){return t instanceof TypeError}}()},{push:function(t){var r=o(this),e=i(r),n=arguments.length;u(e+n);for(var s=0;s<n;s++)r[e]=arguments[s],e++;return a(r,e),e}})},4117:t=>{t.exports=function(t){return null==t}},4270:(t,r,e)=>{var n=e(9565),o=e(4901),i=e(34),a=TypeError;t.exports=function(t,r){var e,u;if("string"===r&&o(e=t.toString)&&!i(u=n(e,t)))return u;if(o(e=t.valueOf)&&!i(u=n(e,t)))return u;if("string"!==r&&o(e=t.toString)&&!i(u=n(e,t)))return u;throw new a("Can't convert object to primitive value")}},4376:(t,r,e)=>{var n=e(2195);t.exports=Array.isArray||function(t){return"Array"===n(t)}},4495:(t,r,e)=>{var n=e(9519),o=e(9039),i=e(4576).String;t.exports=!!Object.getOwnPropertySymbols&&!o(function(){var t=Symbol("symbol detection");return!i(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&n&&n<41})},4527:(t,r,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(t){return t instanceof TypeError}}();t.exports=u?function(t,r){if(o(t)&&!a(t,"length").writable)throw new i("Cannot set read only .length");return t.length=r}:function(t,r){return t.length=r}},4576:function(t){var r=function(t){return t&&t.Math===Math&&t};t.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof global&&global)||r("object"==typeof this&&this)||function(){return this}()||Function("return this")()},4901:t=>{var r="object"==typeof document&&document.all;t.exports=void 0===r&&void 0!==r?function(t){return"function"==typeof t||t===r}:function(t){return"function"==typeof t}},4913:(t,r,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";r.f=n?i?function(t,r,e){if(a(t),r=u(r),a(e),"function"==typeof t&&"prototype"===r&&"value"in e&&v in e&&!e[v]){var n=p(t,r);n&&n[v]&&(t[r]=e.value,e={configurable:l in e?e[l]:n[l],enumerable:f in e?e[f]:n[f],writable:!1})}return c(t,r,e)}:c:function(t,r,e){if(a(t),r=u(r),a(e),o)try{return c(t,r,e)}catch(t){}if("get"in e||"set"in e)throw new s("Accessors not supported");return"value"in e&&(t[r]=e.value),t}},5031:(t,r,e)=>{var n=e(7751),o=e(9504),i=e(8480),a=e(3717),u=e(8551),s=o([].concat);t.exports=n("Reflect","ownKeys")||function(t){var r=i.f(u(t)),e=a.f;return e?s(r,e(t)):r}},5397:(t,r,e)=>{var n=e(7055),o=e(7750);t.exports=function(t){return n(o(t))}},5610:(t,r,e)=>{var n=e(1291),o=Math.max,i=Math.min;t.exports=function(t,r){var e=n(t);return e<0?o(e+r,0):i(e,r)}},5745:(t,r,e)=>{var n=e(7629);t.exports=function(t,r){return n[t]||(n[t]=r||{})}},5917:(t,r,e)=>{var n=e(3724),o=e(9039),i=e(4055);t.exports=!n&&!o(function(){return 7!==Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a})},5966:(t,r,e)=>{var n=e(9306),o=e(4117);t.exports=function(t,r){var e=t[r];return o(e)?void 0:n(e)}},6119:(t,r,e)=>{var n=e(5745),o=e(3392),i=n("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},6198:(t,r,e)=>{var n=e(8014);t.exports=function(t){return n(t.length)}},6298:(t,r,e)=>{e.d(r,{A:()=>n}),e(4114);const n=class{#t;#r;#e;#n;#o;constructor(t){t=Object.assign({negativeWord:"",separatorWord:"",zero:"",spaceSeparator:" "},t),this.#t=t.negativeWord,this.#r=t.separatorWord,this.#e=t.zero,this.#n=t.spaceSeparator}get negativeWord(){return this.#t}get separatorWord(){return this.#r}get zero(){return this.#e}get spaceSeparator(){return this.#n}get wholeNumber(){return this.#o}decimalToCardinal(t){const r=[],e=[...t];let n=0;for(;n<e.length&&"0"===e[n];)r.push(this.zero),n++;return n===e.length?r:[...r,this.toCardinal(BigInt(t))]}floatToCardinal(t){if("number"==typeof t){if(Number.isNaN(t))throw new TypeError("NaN is not an accepted number.");t=t.toString()}else if("string"==typeof t){if(0===(t=t.trim()).length||Number.isNaN(Number(t)))throw new Error('"'+t+'" is not a valid number.')}else if("bigint"!=typeof t)throw new TypeError("Invalid variable type: "+typeof t);let r,e,n=[];if(t<0&&n.push(this.negativeWord),"bigint"==typeof t)r=t;else{const n=t.split(".");r=BigInt(n[0]),e=n[1]}return r<0&&(r=-r),this.#o=r,n=[...n,this.toCardinal(r)],e&&(n.push(this.separatorWord),n=[...n,...this.decimalToCardinal(e)]),n.join(this.spaceSeparator)}}},6395:t=>{t.exports=!1},6518:(t,r,e)=>{var n=e(4576),o=e(7347).f,i=e(6699),a=e(6840),u=e(9433),s=e(7740),c=e(2796);t.exports=function(t,r){var e,p,f,l,v,h=t.target,b=t.global,y=t.stat;if(e=b?n:y?n[h]||u(h,{}):n[h]&&n[h].prototype)for(p in r){if(l=r[p],f=t.dontCallGetSet?(v=o(e,p))&&v.value:e[p],!c(b?p:h+(y?".":"#")+p,t.forced)&&void 0!==f){if(typeof l==typeof f)continue;s(l,f)}(t.sham||f&&f.sham)&&i(l,"sham",!0),a(e,p,l,t)}}},6699:(t,r,e)=>{var n=e(3724),o=e(4913),i=e(6980);t.exports=n?function(t,r,e){return o.f(t,r,i(1,e))}:function(t,r,e){return t[r]=e,t}},6823:t=>{var r=String;t.exports=function(t){try{return r(t)}catch(t){return"Object"}}},6837:t=>{var r=TypeError;t.exports=function(t){if(t>9007199254740991)throw r("Maximum allowed index exceeded");return t}},6840:(t,r,e)=>{var n=e(4901),o=e(4913),i=e(283),a=e(9433);t.exports=function(t,r,e,u){u||(u={});var s=u.enumerable,c=void 0!==u.name?u.name:r;if(n(e)&&i(e,c,u),u.global)s?t[r]=e:a(r,e);else{try{u.unsafe?t[r]&&(s=!0):delete t[r]}catch(t){}s?t[r]=e:o.f(t,r,{value:e,enumerable:!1,configurable:!u.nonConfigurable,writable:!u.nonWritable})}return t}},6969:(t,r,e)=>{var n=e(2777),o=e(757);t.exports=function(t){var r=n(t,"string");return o(r)?r:r+""}},6980:t=>{t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},7040:(t,r,e)=>{var n=e(4495);t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},7055:(t,r,e)=>{var n=e(9504),o=e(9039),i=e(2195),a=Object,u=n("".split);t.exports=o(function(){return!a("z").propertyIsEnumerable(0)})?function(t){return"String"===i(t)?u(t,""):a(t)}:a},7347:(t,r,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;r.f=n?f:function(t,r){if(t=u(t),r=s(r),p)try{return f(t,r)}catch(t){}if(c(t,r))return a(!o(i.f,t,r),t[r])}},7629:(t,r,e)=>{var n=e(6395),o=e(4576),i=e(9433),a="__core-js_shared__",u=t.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:(t,r,e)=>{var n=e(9297),o=e(5031),i=e(7347),a=e(4913);t.exports=function(t,r,e){for(var u=o(r),s=a.f,c=i.f,p=0;p<u.length;p++){var f=u[p];n(t,f)||e&&n(e,f)||s(t,f,c(r,f))}}},7750:(t,r,e)=>{var n=e(4117),o=TypeError;t.exports=function(t){if(n(t))throw new o("Can't call method on "+t);return t}},7751:(t,r,e)=>{var n=e(4576),o=e(4901);t.exports=function(t,r){return arguments.length<2?(e=n[t],o(e)?e:void 0):n[t]&&n[t][r];var e}},8014:(t,r,e)=>{var n=e(1291),o=Math.min;t.exports=function(t){var r=n(t);return r>0?o(r,9007199254740991):0}},8227:(t,r,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;t.exports=function(t){return i(p,t)||(p[t]=u&&i(c,t)?c[t]:f("Symbol."+t)),p[t]}},8480:(t,r,e)=>{var n=e(1828),o=e(8727).concat("length","prototype");r.f=Object.getOwnPropertyNames||function(t){return n(t,o)}},8551:(t,r,e)=>{var n=e(34),o=String,i=TypeError;t.exports=function(t){if(n(t))return t;throw new i(o(t)+" is not an object")}},8622:(t,r,e)=>{var n=e(4576),o=e(4901),i=n.WeakMap;t.exports=o(i)&&/native code/.test(String(i))},8686:(t,r,e)=>{var n=e(3724),o=e(9039);t.exports=n&&o(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})},8727:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},8773:(t,r)=>{var e={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,o=n&&!e.call({1:2},1);r.f=o?function(t){var r=n(this,t);return!!r&&r.enumerable}:e},8981:(t,r,e)=>{var n=e(7750),o=Object;t.exports=function(t){return o(n(t))}},9039:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},9297:(t,r,e)=>{var n=e(9504),o=e(8981),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,r){return i(o(t),r)}},9306:(t,r,e)=>{var n=e(4901),o=e(6823),i=TypeError;t.exports=function(t){if(n(t))return t;throw new i(o(t)+" is not a function")}},9433:(t,r,e)=>{var n=e(4576),o=Object.defineProperty;t.exports=function(t,r){try{o(n,t,{value:r,configurable:!0,writable:!0})}catch(e){n[t]=r}return r}},9504:(t,r,e)=>{var n=e(616),o=Function.prototype,i=o.call,a=n&&o.bind.bind(i,i);t.exports=n?a:function(t){return function(){return i.apply(t,arguments)}}},9519:(t,r,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]),t.exports=o},9565:(t,r,e)=>{var n=e(616),o=Function.prototype.call;t.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},9617:(t,r,e)=>{var n=e(5397),o=e(5610),i=e(6198),a=function(t){return function(r,e,a){var u=n(r),s=i(u);if(0===s)return!t&&-1;var c,p=o(a,s);if(t&&e!=e){for(;s>p;)if((c=u[p++])!=c)return!0}else for(;s>p;p++)if((t||p in u)&&u[p]===e)return t||p||0;return!t&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}}},r={};function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n].call(i.exports,i,i.exports,e),i.exports}e.d=(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var n={};e.d(n,{default:()=>a}),e(4114);var o=e(6298);class i extends o.A{base={0:"không",1:"một",2:"hai",3:"ba",4:"bốn",5:"năm",6:"sáu",7:"bảy",8:"tám",9:"chín",10:"mười",11:"mười một",12:"mười hai",13:"mười ba",14:"mười bốn",15:"mười lăm",16:"mười sáu",17:"mười bảy",18:"mười tám",19:"mười chín"};tens={20:"hai mươi",30:"ba mươi",40:"bốn mươi",50:"năm mươi",60:"sáu mươi",70:"bảy mươi",80:"tám mươi",90:"chín mươi"};thousands={1:"nghìn",2:"triệu",3:"tỷ",4:"nghìn tỷ",5:"trăm nghìn tỷ",6:"Quintillion",7:"Sextillion",8:"Septillion",9:"Octillion",10:"Nonillion",11:"Decillion",12:"Undecillion",13:"Duodecillion",14:"Tredecillion",15:"Quattuordecillion",16:"Sexdecillion",17:"Septendecillion",18:"Octodecillion",19:"Novemdecillion",20:"Vigintillion"};constructor(t){super(Object.assign({negativeWord:"âm",separatorWord:"phẩy",zero:"không"},t))}convertLess100(t){let r=t%10,e=t-r,n=this.tens[e];if(0==r)return n;let o=this.base[r];return 1==r&&(o="mốt"),5==r&&(o="lăm"),n+" "+o}convertLess1000(t){let r=[],e=t%100,n=t-e;return n>0&&r.push(this.base[n/100],"trăm"),0<e&&e<10&&(r.length>0&&r.push("lẻ"),5==e?r.push("năm"):r.push(this.base[e])),e>=10&&r.push(this.toCardinal(e)),r.join(" ")}convertMore1000(t){let r=[],e=t/1000n,n=1;for(;e>=1000n;)e/=1000n,n+=1;let o=t-e*BigInt(Math.pow(1e3,n));return r.push(this.toCardinal(e),this.thousands[n]),o>0n&&(o<=99n&&r.push("lẻ"),r.push(this.toCardinal(o))),r.join(" ")}toCardinal(t){return t<20n?this.base[Number(t)]:t<100n?this.convertLess100(Number(t)):t<1000n?this.convertLess1000(Number(t)):this.convertMore1000(t)}}function a(t,r={}){return new i(r).floatToCardinal(t)}return n.default})());
//# sourceMappingURL=vi.js.map