@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
16 lines (14 loc) • 3.68 kB
JavaScript
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("@lxlib/seed/number-to-chinese",["exports","@angular/core","@angular/common"],r):r(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed["number-to-chinese"]={}),e.ng.core,e.ng.common)}(this,(function(e,r,n){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var o=function(){return(o=Object.assign||function(e){for(var r,n=1,o=arguments.length;n<o;n++)for(var t in r=arguments[n])Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e}).apply(this,arguments)};function t(e,r){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,t,i=n.call(e),l=[];try{for(;(void 0===r||r-- >0)&&!(o=i.next()).done;)l.push(o.value)}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return l}function i(e,r,n){var i,l,u;if(void 0===r&&(r=!0),n=o({minusSymbol:"负",validThrow:!1},n),"number"==typeof e&&(e=e.toString()),!/^-?\d+(\.\d+)?$/.test(e)&&n.validThrow)throw new Error(e+" is invalid number type");l=(i=t(e.split("."),2))[0],u=i[1];var a="";l.startsWith("-")&&(a=n.minusSymbol,l=l.substr(1)),/^-?\d+$/.test(e)&&(u=null),l=(+l).toString();var s={num:r?["","壹","贰","叁","肆","伍","陆","柒","捌","玖","点"]:["","一","二","三","四","五","六","七","八","九","点"],radice:r?["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万亿","拾","佰","仟","兆","拾","佰","仟"]:["","十","百","千","万","十","百","千","亿","十","百","千","万亿","十","百","千","兆","十","百","千"],dec:["角","分","厘","毫"]};r&&(e=(+e).toFixed(5).toString());var c="",f=l.length;if("0"===l||0===f)c="零";else for(var d="",m=0;m<f;m++){var p=+l[m],b=f-m-1,v=m>1&&0!==p&&"0"===l[m-1]?"零":"",y=0===p&&b%4!=0||"0000"===l.substr(m-3,4),h=d,g=s.num[p];d=y?"":s.radice[b],0===m&&"一"===g&&"十"===d&&(g=""),p>1&&"二"===g&&-1===["","十","百"].indexOf(d)&&"十"!==h&&(g="两"),c+=v+g+d}var x="",S=u?u.toString().length:0;if(null===u)x=r?"整":"";else if("0"===u)x="零";else for(m=0;m<S&&!(r&&m>s.dec.length-1);m++){x+=(v="0"===(p=u[m])?"零":"")+(g=s.num[p])+(d=r?s.dec[m]:"")}return a+(r?c+("零"===x?"元整":"元"+x):c+(""===x?"":"点"+x))}var l=function(){function e(){}return e.prototype.transform=function(e,r,n){return void 0===r&&(r=!0),void 0===n&&(n="负"),i(e,r,{minusSymbol:n})},e.decorators=[{type:r.Pipe,args:[{name:"n2c"}]}],e}(),u=[l],a=function(){function e(){}return e.decorators=[{type:r.NgModule,args:[{imports:[n.CommonModule],declarations:u,exports:u}]}],e}();e.NaNumberToChinesePipe=l,e.NumberToChineseModule=a,e.numberToChinese=i,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=numberToChinese.umd.min.js.map