UNPKG

libs-js

Version:

零散的工具函数,无依赖

2 lines (1 loc) 9.37 kB
"use strict";var _isObject=function(e){return"object"==typeof e?null!==e:"function"==typeof e},_anObject=function(e){if(!_isObject(e))throw TypeError(e+" is not an object!");return e},_defined=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},_toObject=function(e){return Object(_defined(e))},ceil=Math.ceil,floor=Math.floor,_toInteger=function(e){return isNaN(e=+e)?0:(0<e?floor:ceil)(e)},min=Math.min,_toLength=function(e){return 0<e?min(_toInteger(e),9007199254740991):0},_stringAt=function(a){return function(e,t){var n,r,o=String(_defined(e)),i=_toInteger(t),c=o.length;return i<0||c<=i?a?"":void 0:(n=o.charCodeAt(i))<55296||56319<n||i+1===c||(r=o.charCodeAt(i+1))<56320||57343<r?a?o.charAt(i):n:a?o.slice(i,i+2):r-56320+(n-55296<<10)+65536}},at=_stringAt(!0),_advanceStringIndex=function(e,t,n){return t+(n?at(e,t).length:1)},toString={}.toString,_cof=function(e){return toString.call(e).slice(8,-1)};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var _core=createCommonjsModule(function(e){var t=e.exports={version:"2.6.11"};"number"==typeof __e&&(__e=t)}),_core_1=_core.version,_global=createCommonjsModule(function(e){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)}),_shared=createCommonjsModule(function(e){var t="__core-js_shared__",n=_global[t]||(_global[t]={});(e.exports=function(e,t){return n[e]||(n[e]=void 0!==t?t:{})})("versions",[]).push({version:_core.version,mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),id=0,px=Math.random(),_uid=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++id+px).toString(36))},_wks=createCommonjsModule(function(e){var t=_shared("wks"),n=_global.Symbol,r="function"==typeof n;(e.exports=function(e){return t[e]||(t[e]=r&&n[e]||(r?n:_uid)("Symbol."+e))}).store=t}),TAG=_wks("toStringTag"),ARG="Arguments"==_cof(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},_classof=function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=tryGet(t=Object(e),TAG))?n:ARG?_cof(t):"Object"==(r=_cof(t))&&"function"==typeof t.callee?"Arguments":r},builtinExec=RegExp.prototype.exec,_regexpExecAbstract=function(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw new TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==_classof(e))throw new TypeError("RegExp#exec called on incompatible receiver");return builtinExec.call(e,t)},_flags=function(){var e=_anObject(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},nativeExec=RegExp.prototype.exec,nativeReplace=String.prototype.replace,patchedExec=nativeExec,LAST_INDEX="lastIndex",UPDATES_LAST_INDEX_WRONG=function(){var e=/a/,t=/b*/g;return nativeExec.call(e,"a"),nativeExec.call(t,"a"),0!==e[LAST_INDEX]||0!==t[LAST_INDEX]}(),NPCG_INCLUDED=void 0!==/()??/.exec("")[1],PATCH=UPDATES_LAST_INDEX_WRONG||NPCG_INCLUDED;PATCH&&(patchedExec=function(e){var t,n,r,o,i=this;return NPCG_INCLUDED&&(n=new RegExp("^"+i.source+"$(?!\\s)",_flags.call(i))),UPDATES_LAST_INDEX_WRONG&&(t=i[LAST_INDEX]),r=nativeExec.call(i,e),UPDATES_LAST_INDEX_WRONG&&r&&(i[LAST_INDEX]=i.global?r.index+r[0].length:t),NPCG_INCLUDED&&r&&1<r.length&&nativeReplace.call(r[0],n,function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(r[o]=void 0)}),r});var _regexpExec=patchedExec,_fails=function(e){try{return!!e()}catch(e){return!0}},_descriptors=!_fails(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),document=_global.document,is=_isObject(document)&&_isObject(document.createElement),_domCreate=function(e){return is?document.createElement(e):{}},_ie8DomDefine=!_descriptors&&!_fails(function(){return 7!=Object.defineProperty(_domCreate("div"),"a",{get:function(){return 7}}).a}),_toPrimitive=function(e,t){if(!_isObject(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!_isObject(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!_isObject(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!_isObject(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},dP=Object.defineProperty,f=_descriptors?Object.defineProperty:function(e,t,n){if(_anObject(e),t=_toPrimitive(t,!0),_anObject(n),_ie8DomDefine)try{return dP(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e},_objectDp={f:f},_propertyDesc=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},_hide=_descriptors?function(e,t,n){return _objectDp.f(e,t,_propertyDesc(1,n))}:function(e,t,n){return e[t]=n,e},hasOwnProperty={}.hasOwnProperty,_has=function(e,t){return hasOwnProperty.call(e,t)},_functionToString=_shared("native-function-to-string",Function.toString),_redefine=createCommonjsModule(function(e){var i=_uid("src"),t="toString",c=(""+_functionToString).split(t);_core.inspectSource=function(e){return _functionToString.call(e)},(e.exports=function(e,t,n,r){var o="function"==typeof n;o&&(_has(n,"name")||_hide(n,"name",t)),e[t]!==n&&(o&&(_has(n,i)||_hide(n,i,e[t]?""+e[t]:c.join(String(t)))),e===_global?e[t]=n:r?e[t]?e[t]=n:_hide(e,t,n):(delete e[t],_hide(e,t,n)))})(Function.prototype,t,function(){return"function"==typeof this&&this[i]||_functionToString.call(this)})}),_aFunction=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},_ctx=function(r,o,e){if(_aFunction(r),void 0===o)return r;switch(e){case 1:return function(e){return r.call(o,e)};case 2:return function(e,t){return r.call(o,e,t)};case 3:return function(e,t,n){return r.call(o,e,t,n)}}return function(){return r.apply(o,arguments)}},PROTOTYPE="prototype",$export=function(e,t,n){var r,o,i,c,a=e&$export.F,u=e&$export.G,l=e&$export.S,f=e&$export.P,_=e&$export.B,s=u?_global:l?_global[t]||(_global[t]={}):(_global[t]||{})[PROTOTYPE],p=u?_core:_core[t]||(_core[t]={}),d=p[PROTOTYPE]||(p[PROTOTYPE]={});for(r in u&&(n=t),n)i=((o=!a&&s&&void 0!==s[r])?s:n)[r],c=_&&o?_ctx(i,_global):f&&"function"==typeof i?_ctx(Function.call,i):i,s&&_redefine(s,r,i,e&$export.U),p[r]!=i&&_hide(p,r,c),f&&d[r]!=i&&(d[r]=i)};_global.core=_core,$export.F=1,$export.G=2,$export.S=4,$export.P=8,$export.B=16,$export.W=32,$export.U=64,$export.R=128;var _export=$export;_export({target:"RegExp",proto:!0,forced:_regexpExec!==/./.exec},{exec:_regexpExec});var SPECIES=_wks("species"),REPLACE_SUPPORTS_NAMED_GROUPS=!_fails(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}),SPLIT_WORKS_WITH_OVERWRITTEN_EXEC=function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2===n.length&&"a"===n[0]&&"b"===n[1]}(),_fixReWks=function(n,e,t){var r=_wks(n),i=!_fails(function(){var e={};return e[r]=function(){return 7},7!=""[n](e)}),o=i?!_fails(function(){var e=!1,t=/a/;return t.exec=function(){return e=!0,null},"split"===n&&(t.constructor={},t.constructor[SPECIES]=function(){return t}),t[r](""),!e}):void 0;if(!i||!o||"replace"===n&&!REPLACE_SUPPORTS_NAMED_GROUPS||"split"===n&&!SPLIT_WORKS_WITH_OVERWRITTEN_EXEC){var c=/./[r],a=t(_defined,r,""[n],function(e,t,n,r,o){return t.exec===_regexpExec?i&&!o?{done:!0,value:c.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}),u=a[0],l=a[1];_redefine(String.prototype,n,u),_hide(RegExp.prototype,r,2==e?function(e,t){return l.call(e,this,t)}:function(e){return l.call(e,this)})}},max=Math.max,min$1=Math.min,floor$1=Math.floor,SUBSTITUTION_SYMBOLS=/\$([$&`']|\d\d?|<[^>]*>)/g,SUBSTITUTION_SYMBOLS_NO_NAMED=/\$([$&`']|\d\d?)/g,maybeToString=function(e){return void 0===e?e:String(e)};_fixReWks("replace",2,function(o,i,E,b){return[function(e,t){var n=o(this),r=null==e?void 0:e[i];return void 0!==r?r.call(e,n,t):E.call(String(n),e,t)},function(e,t){var n=b(E,e,this,t);if(n.done)return n.value;var r=_anObject(e),o=String(this),i="function"==typeof t;i||(t=String(t));var c=r.global;if(c){var a=r.unicode;r.lastIndex=0}for(var u=[];;){var l=_regexpExecAbstract(r,o);if(null===l)break;if(u.push(l),!c)break;""===String(l[0])&&(r.lastIndex=_advanceStringIndex(o,_toLength(r.lastIndex),a))}for(var f="",_=0,s=0;s<u.length;s++){l=u[s];for(var p=String(l[0]),d=max(min$1(_toInteger(l.index),o.length),0),g=[],v=1;v<l.length;v++)g.push(maybeToString(l[v]));var x=l.groups;if(i){var h=[p].concat(g,d,o);void 0!==x&&h.push(x);var S=String(t.apply(void 0,h))}else S=T(p,o,d,g,x,t);_<=d&&(f+=o.slice(_,d)+S,_=d+p.length)}return f+o.slice(_)}];function T(i,c,a,u,l,e){var f=a+i.length,_=u.length,t=SUBSTITUTION_SYMBOLS_NO_NAMED;return void 0!==l&&(l=_toObject(l),t=SUBSTITUTION_SYMBOLS),E.call(e,t,function(e,t){var n;switch(t.charAt(0)){case"$":return"$";case"&":return i;case"`":return c.slice(0,a);case"'":return c.slice(f);case"<":n=l[t.slice(1,-1)];break;default:var r=+t;if(0==r)return e;if(_<r){var o=floor$1(r/10);return 0===o?e:o<=_?void 0===u[o-1]?t.charAt(1):u[o-1]+t.charAt(1):e}n=u[r-1]}return void 0===n?"":n})}});var invisibleAsciiToHtml=function(e){return e=(e=(e=e.replace(/\\n/g,"<br>")).replace(/\\r/g,"<br>")).replace(/\x20/g,"&nbsp;")};module.exports=invisibleAsciiToHtml;