{"size": 14961, "ext": "js", "max_stars_repo_path": "dist/fe-utils.js", "max_stars_repo_name": "zhangyunling/feutils", "max_stars_repo_stars_event_min_datetime": "2019-05-18T08:30:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-30T11:54:03.000Z", "max_issues_repo_path": "dist/fe-utils.js", "max_issues_repo_name": "zhangyunling/feutils", "max_issues_repo_issues_event_min_datetime": "2021-03-01T21:07:31.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T10:44:33.000Z", "max_forks_repo_path": "dist/fe-utils.js", "max_forks_repo_name": "zhangyunling/feutils", "max_forks_repo_forks_event_min_datetime": "2020-03-25T02:26:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-25T02:26:53.000Z"}
{"max_stars_count": 3, "max_issues_count": 9, "max_forks_count": 1, "avg_line_length": 2493.5, "max_line_length": 14875, "alphanum_fraction": 0.6592473765}
/*!
 * @dxbbb/fe-utils v1.1.0
 * (c) 2020 QTT 
 * Released under the MIT License.
 */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.feutils=t():e.feutils=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t),n.d(t,"version",(function(){return r})),n.d(t,"versionCode",(function(){return o})),n.d(t,"isString",(function(){return c})),n.d(t,"isArray",(function(){return s})),n.d(t,"isBoolean",(function(){return f})),n.d(t,"isDate",(function(){return l})),n.d(t,"isError",(function(){return d})),n.d(t,"isFunction",(function(){return p})),n.d(t,"isNumber",(function(){return g})),n.d(t,"isObject",(function(){return y})),n.d(t,"isRegExp",(function(){return m})),n.d(t,"isLogicString",(function(){return T})),n.d(t,"isLeapYear",(function(){return w})),n.d(t,"colorRandom",(function(){return x})),n.d(t,"hexToRgb",(function(){return j})),n.d(t,"rgbToHex",(function(){return M})),n.d(t,"numberFormat",(function(){return O})),n.d(t,"dateFormat",(function(){return H})),n.d(t,"objToStr",(function(){return I})),n.d(t,"strToObj",(function(){return _})),n.d(t,"deepClone",(function(){return B})),n.d(t,"xssEncode",(function(){return W})),n.d(t,"xssDecode",(function(){return Z})),n.d(t,"preciseTimer",(function(){return G})),n.d(t,"dateNature",(function(){return V}));var r="1.1.0",o=1010100;const u={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object RegExp]":"regexp","[object Object]":"object","[object Error]":"error","[object Date]":"date"},i=u.toString;function a(e){if(null==e)return String(e);const t=i.call(e);return u[t]||"object"}function c(e){return"string"===a(e)}function s(e){return"array"===a(e)}function f(e){return"boolean"===a(e)}function l(e){return"date"===a(e)}function d(e){return"error"===a(e)}function p(e){return"function"===a(e)}function g(e){return"number"===a(e)}function y(e){return"object"===a(e)}function m(e){return"regexp"===a(e)}var h=a;const b=/^[a-zA-Z0-9]+((&&|\|\|)[a-zA-Z0-9]+)*$/;function T(e){if(!e||"string"!==h(e))return!1;const t=[],n=e.length;let r=0,o="",u="",i="";for(;r<n;){if(o=e[r],u="",")"===o){if(!t.length)return!1;for(i=t.pop();"("!==i;){if(u=i+u,!t.length)return!1;i=t.pop()}if(!u||!b.test(u))return!1;t.push("a")}else" "!==o&&t.push(o);r++}return u=t.join(""),!(u&&!b.test(u))}function w(e){return e%4==0&&(e%100!=0||e%400==0)}function D(){let e=Math.floor(256*Math.random()).toString(16);return 1===e.length&&(e=`0${e}`),e}function x(){return`#${D()}${D()}${D()}`}function j(e){let t=String(e),n=t.length;if(0!==t.indexOf("#"))throw new TypeError(`hexToRgb传入的参数格式不正确，必须要以#开头：${t}`);if(t=t.substring(1),n=t.length,3!==n&&4!==n||(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]+(t[3]||"")+(t[3]||""),n*=2),6!==n&&8!==n&&/^[0-9a-fA-F]+$/.test(t))throw new TypeError("feutils.hexToRgb传入的参数格式不正确，请检查");const r=parseInt("0x"+t.slice(0,2),16),o=parseInt("0x"+t.slice(2,4),16),u=parseInt("0x"+t.slice(4,6),16);let i=1;return 8===n&&(i=Math.round(100*parseInt("0x"+t.slice(6,8),16)/255)/100),1===i?`rgb(${r},${o},${u})`:`rgba(${r},${o},${u},${i})`}const $=function(e){const t=e.toString(16);return 1===t.length?`0${t}`:t},v=function(e){if(e<0||e>255)throw new TypeError("feutils.rgbToHex参数不合法，小于 0 或者大于 255，请检查");return e};function M(e){let t=String(e).replace(/\s+/g,"");const n=t.indexOf("("),r=t.indexOf(")");if(0!==t.indexOf("rgba(")&&0!==t.indexOf("rgb("))throw new TypeError("feutils.rgbToHex传入的参数格式不正确，请检查");if(-1===n||-1===r||n>=r)throw new TypeError("feutils.rgbToHex传入的参数格式不正确，请检查");t=t.substring(n+1,r);const o=t.split(","),u=o.length;if(3!==u&&4!==u||!/[\d,]+/g.test(t))throw new TypeError("feutils.rgbToHex传入的参数格式不正确，请检查");const i=$(v(Number(o[0]||""))),a=$(v(Number(o[1]||""))),c=$(v(Number(o[2]||"")));let s=Math.round(255*Number(o[3]||""));return 3!==u&&s?(s=$(v(s)),`#${i}${a}${c}${s}`):`#${i}${a}${c}`}function O(e){if(!y(e))throw new Error("numberFormat入参有误！");let t=String(e.number);const n=e.length||3,r=String(e.sep||"")||",",o=[];if("0"===t||"-0"===t||"+0"===t)return t;const u=0===(i=t).indexOf("-")?"-":0===i.indexOf("+")?"+":"";var i;if(t=t.replace(/^[+-]?0*/g,""),!/^\d+$/g.test(t))throw new Error("numberFormat传入的number不是一个有效的整数！");let a=t.length;if(a<=n)return u+t;for(;a>n;)o.unshift(t.substr(a-n,n)),a-=n;return o.unshift(t.substr(0,a)),u+o.join(r)}function E(e){return isNaN(e)?String(e):(e<10?"0":"")+e}function S(e){let t="",n=null;if(!e)return new Date;if(l(e))return e;if(g(e)){if(t=e.toString(10),13===t.length)return new Date(e);if(10===t.length)return new Date(1e3*e);throw new Error("toDate转换为时间对象时出错，请检查您的输入，date="+e)}if(c(e)&&(n=e.replace(/[^\d\s:]+/g,"/")),n=new Date(n),isNaN(n.getDate()))throw new Error("toDate转换为时间对象时出错，请检查您的输入，date="+e);return n}function F(e){const t=[];let n=Math.floor(e/1e3);const r={msecs:e,secs:n,min:Math.floor(n/60),hour:Math.floor(n/3600),day:Math.floor(n/86400),arr:t};return t.push(E(r.day)),n%=86400,t.push(E(Math.floor(n/3600))),n%=3600,t.push(E(Math.floor(n/60))),t.push(E(Math.floor(n%60))),r}const N=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42416,83315,21168,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46752,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448,84835],C=["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"],L=[0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758],k={"0101":"元旦","0106":"中国第13亿人口日","0108":"周恩来逝世纪念日","0115":"释迦如来成道日","0121":"列宁逝世纪念日 国际声援南非日 弥勒佛诞辰","0202":"世界湿地日","0207":"二七大罢工纪念日","0210":"国际气象节","0214":"情人节","0215":"中国12亿人口日","0219":"邓小平逝世纪念日","0221":"国际母语日 反对殖民制度斗争日","0222":"苗族芦笙节","0224":"第三世界青年日","0228":"世界居住条件调查日","0301":"国际海豹日","0303":"全国爱耳日","0305":"学雷锋纪念日 中国青年志愿者服务日","0308":"妇女节","0309":"保护母亲河日","0311":"国际尊严尊敬日","0312":"植树节","0314":"国际警察日 白色情人节","0315":"消费者权益日","0316":"手拉手情系贫困小伙伴全国统一行动日","0317":"中国国医节 国际航海日  爱尔兰圣帕特里克节","0318":"全国科技人才活动日","0321":"世界森林日 消除种族歧视国际日 世界儿歌日 世界睡眠日","0322":"世界水日","0323":"世界气象日","0324":"世界防治结核病日","0325":"全国中小学生安全教育日","0329":"中国黄花岗七十二烈士殉难纪念","0330":"巴勒斯坦国土日","0401":"愚人节","0402":"国际儿童图书日","0407":"世界卫生日","0411":"世界帕金森病日","0421":"全国企业家活动日","0422":"世界地球日 世界法律日","0423":"世界图书和版权日","0424":"亚非新闻工作者日 世界青年反对殖民主义日","0425":"全国预防接种宣传日","0426":"世界知识产权日","0430":"世界交通安全反思日","0501":"国际劳动节","0503":"世界哮喘日 世界新闻自由日","0504":"青年节","0505":"碘缺乏病防治日 日本男孩节","0508":"世界红十字日","0512":"国际护士节","0515":"国际家庭日","0517":"国际电信日","0518":"国际博物馆日","0520":"全国学生营养日 全国母乳喂养宣传日","0523":"国际牛奶日","0526":"世界向人体条件挑战日","0530":"中国“五卅”运动纪念日","0531":"世界无烟日 英国银行休假日","0601":"国际儿童节","0605":"世界环境保护日","0614":"世界献血者日","0617":"防治荒漠化和干旱日","0620":"世界难民日","0622":"中国儿童慈善活动日","0623":"国际奥林匹克日","0625":"全国土地日","0626":"国际禁毒日 国际宪章日 禁止药物滥用和非法贩运国际日 支援酷刑受害者国际日","0630":"世界青年联欢节","0701":"建党节","0702":"国际体育记者日","0706":"朱德逝世纪念日","0707":"抗日战争纪念日","0711":"世界人口日 中国航海日","0726":"世界语创立日","0728":"第一次世界大战爆发","0730":"非洲妇女日","0801":"建军节","0805":"恩格斯逝世纪念日","0806":"国际电影节","0808":"中国男子节(爸爸节)","0812":"国际青年节","0813":"国际左撇子日","0815":"抗日战争胜利纪念","0826":"全国律师咨询日","0902":"日本签署无条件投降书日","0903":"中国抗日战争胜利纪念日","0905":"瑞士萨永中世纪节","0906":"帕瓦罗蒂去世","0908":"国际扫盲日 国际新闻工作者日","0909":"毛泽东逝世纪念日","0910":"教师节","0914":"世界清洁地球日","0916":"国际臭氧层保护日 中国脑健康日","0918":"九·一八事变纪念日","0920":"国际爱牙日","0921":"世界停火日 预防世界老年性痴呆宣传日","0927":"世界旅游日","0928":"孔子诞辰","0930":"国际翻译日",1001:"国庆节",1002:"国庆节假日 国际和平与民主自由斗争日",1003:"国庆节假日",1004:"世界动物日",1005:"国际教师节",1006:"中国老年节",1008:"全国高血压日 世界视觉日",1009:"世界邮政日 万国邮联日",1010:"辛亥革命纪念日 世界精神卫生日 世界居室卫生日",1013:"世界保健日 国际教师节 中国少年先锋队诞辰日 世界保健日",1014:"世界标准日",1015:"国际盲人节(白手杖节)",1016:"世界粮食日",1017:"世界消除贫困日",1020:"世界骨质疏松日",1022:"世界传统医药日",1024:"联合国日 世界发展新闻日",1028:"中国男性健康日",1031:"万圣节",1102:"达摩祖师圣诞",1106:"柴科夫斯基逝世悼念日",1107:"十月社会主义革命纪念日",1108:"中国记者日",1109:"全国消防安全宣传教育日",1110:"世界青年节",1111:"光棍节",1112:"孙中山诞辰纪念日",1114:"世界糖尿病日",1115:"泰国大象节",1117:"国际大学生节 世界学生节 世界戒烟日",1120:"世界儿童日",1121:"世界问候日 世界电视日",1129:"国际声援巴勒斯坦人民国际日",1201:"世界艾滋病日",1202:"废除一切形式奴役世界日",1203:"世界残疾人日",1204:"全国法制宣传日",1205:"国际经济和社会发展志愿人员日 世界弱能人士日",1207:"国际民航日",1208:"国际儿童电视日",1209:"世界足球日 一二·九运动纪念日",1210:"世界人权日",1211:"世界防止哮喘日",1212:"西安事变纪念日",1213:"南京大屠杀纪念日",1214:"国际儿童广播电视节",1215:"世界强化免疫日",1220:"澳门回归纪念",1221:"国际篮球日",1224:"平安夜",1225:"圣诞节",1226:"毛泽东诞辰纪念日",1229:"国际生物多样性日"},U={"0101":"春节","0115":"元宵节","0505":"端午节","0707":"七夕情人节","0715":"中元节","0815":"中秋节","0909":"重阳节",1208:"腊八节",1223:"小年","0100":"除夕"},P={"0150":"世界麻风日","0351":"全国中小学生安全教育日","0453":"秘书节","0512":"国世界哮喘日","0520":"母亲节","0530":"全国助残日","0532":"国际牛奶日","0626":"中国文化遗产日","0630":"父亲节","0716":"国际合作节","0730":"被奴役国家周","0932":"国际和平日","0936":"全民国防教育日","0940":"国际聋人节 世界儿童日","0950":"世界海事日 世界心脏病日",1011:"国际住房日 世界建筑日 世界人居日",1023:"国际减轻自然灾害日(减灾日)",1024:"世界视觉日",1144:"感恩节",1220:"国际儿童电视广播日"},R={yyyy:function(e){return e.getFullYear()},mm:function(e){return E(e.getMonth()+1)},dd:function(e){return E(e.getDate())},hh:function(e){return E(e.getHours())},ii:function(e){return E(e.getMinutes())},ss:function(e){return E(e.getSeconds())}};function H(e={}){const t=e.format||"yyyy/mm/dd hh:ii",n=S(e.date);return t.replace(/yyyy|mm|dd|hh|ii|ss/g,(function(e){return R[e](n)}))}function I(e={},t="&"){const n=[];let r="";for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(`${r}=${encodeURIComponent(String(e[r]))}`);return n.join(t)}const Y={undefined:void 0,null:null,false:!1,true:!0};function _(e="",t="&"){const n={};return e?(e.split(t).forEach(t=>{const r=t.split("="),o=r[0]||"";let u=r[1]||"undefined";if(!o||r.length>2)throw new Error("您输入的格式不正确，请确认："+e);u=Object.prototype.hasOwnProperty.call(Y,u)?Y[u]:decodeURIComponent(u),n[o]=u}),n):n}const A=function(e){let t="";return null===e||"object"!=typeof e?e:l(e)?(t=new Date(e.getTime()),t):e&&s(e)?q(e):e&&y(e)?z(e):e},q=function(e=[]){const t=[];let n=0;const r=e.length;for(;n<r;n++)t.push(A(e[n]));return t},z=function(e={}){const t={};let n="";for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=A(e[n]));return t};function B(e){if(e&&s(e))return q(e);if(e&&y(e))return z(e);throw new Error("deepClone传入参数格式不正确，请传入对象，数组格式")}function W(e=""){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/\s/g,"&nbsp;"):e}function Z(e=""){return e?e.replace(/&amp;?/g,"&").replace(/&lt;?/g,"<").replace(/&quot;?/g,'"').replace(/&#39;?/g,"'").replace(/&nbsp;?/g," "):e}function G(e){const t=S(e.distTime).getTime(),n=S(e.curTime).getTime();let r=(new Date).getTime();const o=r+t-n;let u=0;const i=function(){const t=(new Date).getTime(),n=o-t;let a=0;n<=0?e.callback(F(0)):(e.callback(F(n)),a=t-r>500?2e3-t+r:1e3-t+r,u=setTimeout(i,a),r=t)};return i(),{clear:function(){clearTimeout(u)}}}const J=H({format:"yyyy/mm/dd"}),K=new Date(J).getTime(),Q={lYearDays:function(e){let t=32768,n=348;for(;t>8;t>>=1)n+=N[e-1900]&t?1:0;return n+Q.leapDays(e)},leapDays:function(e){return Q.leapMonth(e)?65536&N[e-1900]?30:29:0},leapMonth:function(e){return 15&N[e-1900]},monthDays:function(e,t){return N[e-1900]&65536>>t?30:29},sTerm:function(e,t){return 2009===e&&2===t&&(L[t]=43467),new Date(31556925974.7*(e-1900)+6e4*L[t]+Date.UTC(1900,0,6,2,5)).getUTCDate()},easter:function(e){const t=Q.sTerm(e,5),n=new Date(Date.UTC(e,2,t,0,0,0,0)),r=Q.lunar(n);let o=0;o=r.day<15?15-r.day:(r.isLeap?Q.leapDays(e):Q.monthDays(e,r.month))-r.day+15;const u=new Date(n.getTime()+864e5*o),i=new Date(u.getTime()+864e5*(7-u.getUTCDay()));return{m:i.getUTCMonth(),d:i.getUTCDate()}},lunar:function(e){let t=1900,n=0,r=(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())-Date.UTC(1900,0,31))/864e5;for(;t<2150&&r>0;t++)n=Q.lYearDays(t),r-=n;r<0&&(r+=n,t--);const o={year:t,leap:Q.leapMonth(t),isLeap:!1,month:0,day:0};for(t=1;t<13&&r>0;t++)o.leap>0&&t===o.leap+1&&!1===o.isLeap?(--t,o.isLeap=!0,n=Q.leapDays(o.year)):n=Q.monthDays(o.year,t),!0===o.isLeap&&t===o.leap+1&&(o.isLeap=!1),r-=n;return 0===r&&o.leap>0&&t===o.leap+1&&(o.isLeap?o.isLeap=!1:(o.isLeap=!0,--t)),r<0&&(r+=n,--t),o.month=t,o.day=r+1,o},getDate:function(e,t){const n={year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),week:e.getDay()};t.solar=n,J===H({date:e,format:"yyyy/mm/dd"})?(t.isToday=!0,t.distanceToday=0):(t.isToday=!1,t.distanceToday=Math.floor((e.getTime()-K)/864e5))},solarTerms:function(e){const t=e.solar,n=t.year,r=t.month-1,o=t.day;let u=Q.sTerm(n,2*r);u!==o?(u=Q.sTerm(n,2*r+1),e.solarTerms=u===o?C[2*r+1]:""):e.solarTerms=C[2*r]},addEstDay:function(e){const t=e.solar,n=t.year,r=t.month-1,o=t.day;if(2!==r&&3!==r)return;const u=Q.easter(n);r===u.m&&o===u.d&&(e.festival.estDay="复活节")},getWeekNumber:function(e){const t=e.year,n=e.month,r=new Date(`${t}/${n}/1`).getDay();let o=e.day-(7-r),u=1;for(;o>=7;)u++,o-=7;return u},weekFestival:function(e){const t=e.solar,n=E(t.month),r=t.week,o=`${n}${Q.getWeekNumber(t)}${r}`;e.festival.week=P[o]||""},solarFestival:function(e){const t=e.solar,n=E(t.month)+E(t.day);e.festival.solar=k[n]||""},lunarFestival:function(e){const t=e.lunar,n=E(t.month)+E(t.day);e.festival.lunar=U[n]||""}};function V(e){const t=S(e),n={festival:{solar:"",week:"",lunar:""}};if(!l(t))throw new TypeError("在调用feutils.dateNature时，传入的参数不是一个合法的Date实例！date="+e);return n.lunar=Q.lunar(t),Q.getDate(t,n),Q.solarTerms(n),Q.addEstDay(n),Q.solarFestival(n),Q.weekFestival(n),Q.lunarFestival(n),n}}])}));