UNPKG

libs-js

Version:

零散的工具函数,无依赖

2 lines (1 loc) 13.9 kB
"use strict";var _isObject=function(e){return"object"==typeof e?null!==e:"function"==typeof e},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__",r=_global[t]||(_global[t]={});(e.exports=function(e,t){return r[e]||(r[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"),r=_global.Symbol,n="function"==typeof r;(e.exports=function(e){return t[e]||(t[e]=n&&r[e]||(n?r:_uid)("Symbol."+e))}).store=t}),MATCH=_wks("match"),_isRegexp=function(e){var t;return _isObject(e)&&(void 0!==(t=e[MATCH])?!!t:"RegExp"==_cof(e))},_anObject=function(e){if(!_isObject(e))throw TypeError(e+" is not an object!");return e},_aFunction=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},SPECIES=_wks("species"),_speciesConstructor=function(e,t){var r,n=_anObject(e).constructor;return void 0===n||null==(r=_anObject(n)[SPECIES])?t:_aFunction(r)},ceil=Math.ceil,floor=Math.floor,_toInteger=function(e){return isNaN(e=+e)?0:(0<e?floor:ceil)(e)},_defined=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},_stringAt=function(u){return function(e,t){var r,n,o=String(_defined(e)),i=_toInteger(t),c=o.length;return i<0||c<=i?u?"":void 0:(r=o.charCodeAt(i))<55296||56319<r||i+1===c||(n=o.charCodeAt(i+1))<56320||57343<n?u?o.charAt(i):r:u?o.slice(i,i+2):n-56320+(r-55296<<10)+65536}},at=_stringAt(!0),_advanceStringIndex=function(e,t,r){return t+(r?at(e,t).length:1)},min=Math.min,_toLength=function(e){return 0<e?min(_toInteger(e),9007199254740991):0},TAG=_wks("toStringTag"),ARG="Arguments"==_cof(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},_classof=function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=Object(e),TAG))?r:ARG?_cof(t):"Object"==(n=_cof(t))&&"function"==typeof t.callee?"Arguments":n},builtinExec=RegExp.prototype.exec,_regexpExecAbstract=function(e,t){var r=e.exec;if("function"==typeof r){var n=r.call(e,t);if("object"!=typeof n)throw new TypeError("RegExp exec method returned something other than an Object or null");return n}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,r,n,o,i=this;return NPCG_INCLUDED&&(r=new RegExp("^"+i.source+"$(?!\\s)",_flags.call(i))),UPDATES_LAST_INDEX_WRONG&&(t=i[LAST_INDEX]),n=nativeExec.call(i,e),UPDATES_LAST_INDEX_WRONG&&n&&(i[LAST_INDEX]=i.global?n.index+n[0].length:t),NPCG_INCLUDED&&n&&1<n.length&&nativeReplace.call(n[0],r,function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(n[o]=void 0)}),n});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 r,n;if(t&&"function"==typeof(r=e.toString)&&!_isObject(n=r.call(e)))return n;if("function"==typeof(r=e.valueOf)&&!_isObject(n=r.call(e)))return n;if(!t&&"function"==typeof(r=e.toString)&&!_isObject(n=r.call(e)))return n;throw TypeError("Can't convert object to primitive value")},dP=Object.defineProperty,f=_descriptors?Object.defineProperty:function(e,t,r){if(_anObject(e),t=_toPrimitive(t,!0),_anObject(r),_ie8DomDefine)try{return dP(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.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,r){return _objectDp.f(e,t,_propertyDesc(1,r))}:function(e,t,r){return e[t]=r,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,r,n){var o="function"==typeof r;o&&(_has(r,"name")||_hide(r,"name",t)),e[t]!==r&&(o&&(_has(r,i)||_hide(r,i,e[t]?""+e[t]:c.join(String(t)))),e===_global?e[t]=r:n?e[t]?e[t]=r:_hide(e,t,r):(delete e[t],_hide(e,t,r)))})(Function.prototype,t,function(){return"function"==typeof this&&this[i]||_functionToString.call(this)})}),_ctx=function(n,o,e){if(_aFunction(n),void 0===o)return n;switch(e){case 1:return function(e){return n.call(o,e)};case 2:return function(e,t){return n.call(o,e,t)};case 3:return function(e,t,r){return n.call(o,e,t,r)}}return function(){return n.apply(o,arguments)}},PROTOTYPE="prototype",$export=function(e,t,r){var n,o,i,c,u=e&$export.F,a=e&$export.G,_=e&$export.S,s=e&$export.P,l=e&$export.B,f=a?_global:_?_global[t]||(_global[t]={}):(_global[t]||{})[PROTOTYPE],p=a?_core:_core[t]||(_core[t]={}),g=p[PROTOTYPE]||(p[PROTOTYPE]={});for(n in a&&(r=t),r)i=((o=!u&&f&&void 0!==f[n])?f:r)[n],c=l&&o?_ctx(i,_global):s&&"function"==typeof i?_ctx(Function.call,i):i,f&&_redefine(f,n,i,e&$export.U),p[n]!=i&&_hide(p,n,c),s&&g[n]!=i&&(g[n]=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$1=_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 r="ab".split(e);return 2===r.length&&"a"===r[0]&&"b"===r[1]}(),_fixReWks=function(r,e,t){var n=_wks(r),i=!_fails(function(){var e={};return e[n]=function(){return 7},7!=""[r](e)}),o=i?!_fails(function(){var e=!1,t=/a/;return t.exec=function(){return e=!0,null},"split"===r&&(t.constructor={},t.constructor[SPECIES$1]=function(){return t}),t[n](""),!e}):void 0;if(!i||!o||"replace"===r&&!REPLACE_SUPPORTS_NAMED_GROUPS||"split"===r&&!SPLIT_WORKS_WITH_OVERWRITTEN_EXEC){var c=/./[n],u=t(_defined,n,""[r],function(e,t,r,n,o){return t.exec===_regexpExec?i&&!o?{done:!0,value:c.call(t,r,n)}:{done:!0,value:e.call(r,t,n)}:{done:!1}}),a=u[0],_=u[1];_redefine(String.prototype,r,a),_hide(RegExp.prototype,n,2==e?function(e,t){return _.call(e,this,t)}:function(e){return _.call(e,this)})}},$min=Math.min,$push=[].push,$SPLIT="split",LENGTH="length",LAST_INDEX$1="lastIndex",MAX_UINT32=4294967295,SUPPORTS_Y=!_fails(function(){RegExp(MAX_UINT32,"y")});_fixReWks("split",2,function(o,i,E,x){var h;return h="c"=="abbc"[$SPLIT](/(b)*/)[1]||4!="test"[$SPLIT](/(?:)/,-1)[LENGTH]||2!="ab"[$SPLIT](/(?:ab)*/)[LENGTH]||4!="."[$SPLIT](/(.?)(.?)/)[LENGTH]||1<"."[$SPLIT](/()()/)[LENGTH]||""[$SPLIT](/.?/)[LENGTH]?function(e,t){var r=String(this);if(void 0===e&&0===t)return[];if(!_isRegexp(e))return E.call(r,e,t);for(var n,o,i,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),a=0,_=void 0===t?MAX_UINT32:t>>>0,s=new RegExp(e.source,u+"g");(n=_regexpExec.call(s,r))&&!(a<(o=s[LAST_INDEX$1])&&(c.push(r.slice(a,n.index)),1<n[LENGTH]&&n.index<r[LENGTH]&&$push.apply(c,n.slice(1)),i=n[0][LENGTH],a=o,c[LENGTH]>=_));)s[LAST_INDEX$1]===n.index&&s[LAST_INDEX$1]++;return a===r[LENGTH]?!i&&s.test("")||c.push(""):c.push(r.slice(a)),c[LENGTH]>_?c.slice(0,_):c}:"0"[$SPLIT](void 0,0)[LENGTH]?function(e,t){return void 0===e&&0===t?[]:E.call(this,e,t)}:E,[function(e,t){var r=o(this),n=null==e?void 0:e[i];return void 0!==n?n.call(e,r,t):h.call(String(r),e,t)},function(e,t){var r=x(h,e,this,t,h!==E);if(r.done)return r.value;var n=_anObject(e),o=String(this),i=_speciesConstructor(n,RegExp),c=n.unicode,u=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(SUPPORTS_Y?"y":"g"),a=new i(SUPPORTS_Y?n:"^(?:"+n.source+")",u),_=void 0===t?MAX_UINT32:t>>>0;if(0===_)return[];if(0===o.length)return null===_regexpExecAbstract(a,o)?[o]:[];for(var s=0,l=0,f=[];l<o.length;){a.lastIndex=SUPPORTS_Y?l:0;var p,g=_regexpExecAbstract(a,SUPPORTS_Y?o:o.slice(l));if(null===g||(p=$min(_toLength(a.lastIndex+(SUPPORTS_Y?0:l)),o.length))===s)l=_advanceStringIndex(o,l,c);else{if(f.push(o.slice(s,l)),f.length===_)return f;for(var d=1;d<=g.length-1;d++)if(f.push(g[d]),f.length===_)return f;l=s=p}}return f.push(o.slice(s)),f}]}),_fixReWks("match",1,function(n,o,_,s){return[function(e){var t=n(this),r=null==e?void 0:e[o];return void 0!==r?r.call(e,t):new RegExp(e)[o](String(t))},function(e){var t=s(_,e,this);if(t.done)return t.value;var r=_anObject(e),n=String(this);if(!r.global)return _regexpExecAbstract(r,n);for(var o,i=r.unicode,c=[],u=r.lastIndex=0;null!==(o=_regexpExecAbstract(r,n));){var a=String(o[0]);""===(c[u]=a)&&(r.lastIndex=_advanceStringIndex(n,_toLength(r.lastIndex),i)),u++}return 0===u?null:c}]});var f$1={}.propertyIsEnumerable,_objectPie={f:f$1},_iobject=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==_cof(e)?e.split(""):Object(e)},_toIobject=function(e){return _iobject(_defined(e))},gOPD=Object.getOwnPropertyDescriptor,f$2=_descriptors?gOPD:function(e,t){if(e=_toIobject(e),t=_toPrimitive(t,!0),_ie8DomDefine)try{return gOPD(e,t)}catch(e){}if(_has(e,t))return _propertyDesc(!_objectPie.f.call(e,t),e[t])},_objectGopd={f:f$2},check=function(e,t){if(_anObject(e),!_isObject(t)&&null!==t)throw TypeError(t+": can't set as prototype!")},_setProto={set:Object.setPrototypeOf||("__proto__"in{}?function(e,r,n){try{(n=_ctx(Function.call,_objectGopd.f(Object.prototype,"__proto__").set,2))(e,[]),r=!(e instanceof Array)}catch(e){r=!0}return function(e,t){return check(e,t),r?e.__proto__=t:n(e,t),e}}({},!1):void 0),check:check},setPrototypeOf=_setProto.set,_inheritIfRequired=function(e,t,r){var n,o=t.constructor;return o!==r&&"function"==typeof o&&(n=o.prototype)!==r.prototype&&_isObject(n)&&setPrototypeOf&&setPrototypeOf(e,n),e},max=Math.max,min$1=Math.min,_toAbsoluteIndex=function(e,t){return(e=_toInteger(e))<0?max(e+t,0):min$1(e,t)},_arrayIncludes=function(u){return function(e,t,r){var n,o=_toIobject(e),i=_toLength(o.length),c=_toAbsoluteIndex(r,i);if(u&&t!=t){for(;c<i;)if((n=o[c++])!=n)return!0}else for(;c<i;c++)if((u||c in o)&&o[c]===t)return u||c||0;return!u&&-1}},shared=_shared("keys"),_sharedKey=function(e){return shared[e]||(shared[e]=_uid(e))},arrayIndexOf=_arrayIncludes(!1),IE_PROTO=_sharedKey("IE_PROTO"),_objectKeysInternal=function(e,t){var r,n=_toIobject(e),o=0,i=[];for(r in n)r!=IE_PROTO&&_has(n,r)&&i.push(r);for(;t.length>o;)_has(n,r=t[o++])&&(~arrayIndexOf(i,r)||i.push(r));return i},_enumBugKeys="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),hiddenKeys=_enumBugKeys.concat("length","prototype"),f$3=Object.getOwnPropertyNames||function(e){return _objectKeysInternal(e,hiddenKeys)},_objectGopn={f:f$3},SPECIES$2=_wks("species"),_setSpecies=function(e){var t=_global[e];_descriptors&&t&&!t[SPECIES$2]&&_objectDp.f(t,SPECIES$2,{configurable:!0,get:function(){return this}})},dP$1=_objectDp.f,gOPN=_objectGopn.f,$RegExp=_global.RegExp,Base=$RegExp,proto=$RegExp.prototype,re1=/a/g,re2=/a/g,CORRECT_NEW=new $RegExp(re1)!==re1;if(_descriptors&&(!CORRECT_NEW||_fails(function(){return re2[_wks("match")]=!1,$RegExp(re1)!=re1||$RegExp(re2)==re2||"/a/i"!=$RegExp(re1,"i")}))){$RegExp=function(e,t){var r=this instanceof $RegExp,n=_isRegexp(e),o=void 0===t;return!r&&n&&e.constructor===$RegExp&&o?e:_inheritIfRequired(CORRECT_NEW?new Base(n&&!o?e.source:e,t):Base((n=e instanceof $RegExp)?e.source:e,n&&o?_flags.call(e):t),r?this:proto,$RegExp)};for(var proxy=function(t){t in $RegExp||dP$1($RegExp,t,{configurable:!0,get:function(){return Base[t]},set:function(e){Base[t]=e}})},keys=gOPN(Base),i=0;keys.length>i;)proxy(keys[i++]);(proto.constructor=$RegExp).prototype=proto,_redefine(_global,"RegExp",$RegExp)}_setSpecies("RegExp");var _getVal=function(e){var t,r=window.location.href;return t=new RegExp(e+"=([^&?]*)","gi"),r.match(t),r.match(t)?decodeURIComponent(r.match(t)[0].substr(e.length+1).split("#")[0]):null},queryString=function(e){if(e.constructor==String)return _getVal(e);if(e.constructor==Object){var t;for(var r in e)e.hasOwnProperty(r)&&(t=_getVal(r))&&(e[r]=t);return e}if(e.constructor!=Array)return null;for(var n=e.length;n--;)e[n]=_getVal(e[n]);return e};module.exports=queryString;