money-uppercase
Version:
1 lines • 2.46 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.moneyUppercase=r():t.moneyUppercase=r()}(self,(function(){return(()=>{"use strict";var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r)},r={};function e(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,u=[],a=!0,i=!1;try{for(e=e.call(t);!(a=(n=e.next()).done)&&(u.push(n.value),!r||u.length!==r);a=!0);}catch(t){i=!0,o=t}finally{try{a||null==e.return||e.return()}finally{if(i)throw o}}return u}}(t,r)||function(t,r){if(t){if("string"==typeof t)return n(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}t.d(r,{default:()=>i});var o=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],u=["元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰","仟","万"],a=["角","分"];function i(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"欠";if(t=parseFloat(t),isNaN(t))return"零元整";var n=t<0?r:"";if(t=Math.abs(t),"[object Number]"===Object.prototype.toString.call(t)&&t>.01){for(var i=[],l=String(t).split(".").map((function(t){return t.split("").map((function(t){return 1*t}))})),f=e(l,2),c=f[0],p=f[1],s=c.length,y=s-1,h=s-5,d=s-9,b=s-13,m=s-17,v=s>1||c[0]>0,g=p&&(p[0]>0||p[1]>0),j=c[h-1]>0||c[h-2]>0||c[h-3]>0,S=s-u.length,A=0,O=s-1;O>=0;O--)0===c[O]&&(O===h||O===d||O===b||O===m)&&c[O+1]>0&&i.unshift(o[c[O]]),(c[O]>0||O===y&&v||O===h&&j||O===d||O===b||O===m)&&i.unshift(u[A]),(c[O]>0||c[O+1]>0&&O!==h&&O!==d&&O!==b&&O!==m||O<=S)&&i.unshift(o[c[O]]),A++;return g?((p[0]>0||v)&&i.push(o[p[0]]),p[0]>0&&i.push(a[0]),p[1]>0&&(i.push(o[p[1]]),i.push(a[1]))):i.push("整"),n+i.join("")}return"零元整"}return r.default})()}));