@bassist/utils
Advanced tools
Comparing version 0.6.0 to 0.7.0
/** | ||
* name: @bassist/utils | ||
* version: v0.6.0 | ||
* version: v0.7.0 | ||
* description: Opinionated collection of common JavaScript / TypeScript utils by @chengpeiquan . | ||
@@ -9,2 +9,2 @@ * author: chengpeiquan <chengpeiquan@chengpeiquan.com> | ||
*/ | ||
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@withtypes/mime")):typeof define=="function"&&define.amd?define(["exports","@withtypes/mime"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.Utils={},o["@withtypes/mime"]))})(this,function(o,a){"use strict";var pe=Object.defineProperty;var We=(o,a,c)=>a in o?pe(o,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):o[a]=c;var h=(o,a,c)=>(We(o,typeof a!="symbol"?a+"":a,c),c);const c={isSupported:typeof navigator>"u"?!1:Boolean(navigator.clipboard),async copy(e){if(!this.isSupported)return!1;const i=e.innerText||e.value;return await this.write(i)},async cut(e){return!this.isSupported||!await this.copy(e)?!1:(e.value="",!0)},async read(){return this.isSupported?await navigator.clipboard.readText():""},async write(e){return this.isSupported?(await navigator.clipboard.writeText(e),!0):!1}};function s(){return typeof window<"u"?navigator.userAgent.toLowerCase():""}const p=["Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36","Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36","Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36","Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36","Mozilla/5.0 (Linux; U; Android 8.0.0; zh-CN; MHA-AL00 Build/HUAWEIMHA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.1.4.994 Mobile Safari/537.36","Mozilla/5.0 (Linux; Android 8.1; EML-AL00 Build/HUAWEIEML-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.143 Crosswalk/24.53.595.0 XWEB/358 MMWEBSDK/23 Mobile Safari/537.36 MicroMessenger/6.7.2.1340(0x2607023A) NetType/4G Language/zh_CN","Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/044207 Mobile Safari/537.36 MicroMessenger/6.7.3.1340(0x26070332) NetType/4G Language/zh_CN Process/tools","Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13","MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","Mozilla/5.0 (Linux; Android 7.1.1; MI 6 Build/NMF26X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/043807 Mobile Safari/537.36 MicroMessenger/6.6.1.1220(0x26060135) NetType/WIFI Language/zh_CN","Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043632 Safari/537.36 MicroMessenger/6.6.1.1220(0x26060135) NetType/WIFI Language/zh_CN","Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1","Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1","Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1","Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.3; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4","Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/603.2.5 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.5","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/58.0.3029.110 Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 OPR/45.0.2552.888","Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/603.2.5 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.5","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36","Mozilla/5.0 (iPad; CPU OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.0 Mobile/14F89 Safari/602.1","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36 OPR/45.0.2552.812","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0; Trident/5.0)","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Trident/5.0)","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (iPad; CPU OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1","Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7","Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko","Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"],M=typeof window<"u",G=!M,L=/iPhone|phone|android|iPod|pad|iPad/i;function W(){return L.test(s())}const C=W(),_=!W(),O=/Android/i.test(s()),H=/iPhone|iPod|iPad|iOS/i.test(s()),v=/uni-app|html5plus/.test(s()),y=/MicroMessenger/i.test(s()),N=/\sQQ|mqqbrowser|qzone|qqbrowser/i.test(s()),x=/mqqbrowser|qqbrowser/i.test(s()),X=/qzone\/.*_qz_([\d.]+)/i.test(s()),I=/(weibo).*weibo__([\d.]+)/i.test(s()),E=/(baiduboxapp)\/([\d.]+)/i.test(s());function B(e,{immediate:i}={immediate:!0}){M&&(i&&window.addEventListener("load",e,!1),window.addEventListener("orientationchange"in window?"orientationchange":"resize",e,!1))}function S(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function T(e){return S(e)==="object"}function u(e,i){return T(e)?Object.prototype.hasOwnProperty.call(e,i):!1}const m={};class P{constructor(i){h(this,"data");this.data={};const n=u(m,i);this.data=n?m[i].data:{},n||(m[i]=this)}get length(){return Object.keys(this.data).length}clear(){this.data={}}getItem(i){return u(this.data,i)?this.data[i]:null}setItem(i,n){this.data[i]=n}removeItem(i){u(this.data,i)&&delete this.data[i]}key(i){const n=Object.keys(this.data);return i>n.length?null:n[i]}}class z{constructor(i,n){h(this,"prefix");h(this,"storage");this.prefix=i,this.storage=M?window[n]:new P(i)}get(i){const n=this.storage.getItem(`${this.prefix}-${i}`);if(!n)return n;try{return n==="true"?!0:n==="false"?!1:n==="null"?null:n==="undefined"?void 0:JSON.parse(n)}catch{return n}}set(i,n){try{const l=S(n)==="string"?n:JSON.stringify(n);this.storage.setItem(`${this.prefix}-${i}`,l)}catch(t){console.log(t)}}remove(i){this.storage.removeItem(`${this.prefix}-${i}`)}clear(){this.list().forEach(n=>{this.remove(n)})}count(){return this.list().length}list(){if(!this.prefix)return[];const i=[],n=this.storage.length;for(let t=0;t<n;t++){const l=this.storage.key(t);l!=null&&l.startsWith(this.prefix)&&i.push(l.replace(`${this.prefix}-`,""))}return i}}class F extends z{constructor(i){super(i,"localStorage")}}class Q extends z{constructor(i){super(i,"sessionStorage")}}function f(){return M?window.matchMedia("(prefers-color-scheme: dark)").matches:!1}const U=f(),R=!f();function V(){return f()?"dark":"light"}function D(e){return new Promise(i=>{setTimeout(()=>{i()},e)})}function A(e){return e.startsWith("data")&&e.includes("base64")?e.split(",")[0].replace(/data:(.*);base64/,"$1"):a.getType(e)||""}function g(e){return a.getExtension(e)||""}function $(e){const i=A(e);return g(i)}function q(e,i=!1){return e=e?String(e):"",e=e.replace(/[^\d]/g,""),e&&!i&&(e=parseInt(e)),String(e)}function j(e){if(e=String(e),!e)return"0.00";const i=e.split("."),n=i[0],t=i[1];return i.length===1?`${n}.00`:t.length===1?`${e}0`:Number(e).toFixed(2)}function Z(e,i){return String(e).length>i?String(e).slice(0,i)+"…":String(e)}function J([e,...i]){return e?(e==null?void 0:e.toUpperCase())+i.join("").toLowerCase():""}function Y({type:e,id:i,resource:n}){return new Promise((t,l)=>{if(!M||document.querySelector(i)){l();return}function d(r){r.addEventListener("load",t),r.addEventListener("error",l),r.addEventListener("abort",l)}switch(e){case"js":{const r=document.createElement("script");r.async=!0,r.src=n,d(r),document.head.appendChild(r);break}case"css":{const r=document.createElement("link");r.id=i,r.rel="stylesheet",r.href=n,d(r),document.head.appendChild(r);break}case"style":{const r=document.createElement("style");r.id=i,d(r),document.head.appendChild(r),r.appendChild(document.createTextNode(n));break}}})}function K(e){let i="";if(M){const{search:t}=window.location;i=t}if(typeof e=="string"&&e.startsWith("http")){const t=e.indexOf("?");i=t===-1?"":e.slice(t)}if(i.includes("#")){const t=i.indexOf("#");i=i.slice(0,t)}if(!i.length)return{};const n={};return i.slice(1).split("&").forEach(t=>{const[l,d]=t.split("=");n[l]=decodeURIComponent(d)}),n}function ee(e){const i=K(e),n={};return Object.keys(i).forEach(l=>{l!=="path"&&(n[l]=i[l])}),{path:i.path||"",params:n}}function ie(e,i){return K(i)[e]||""}function oe(e){return T(e)?Object.keys(e).map(i=>`${i}=${encodeURIComponent(String(e[i]))}`).join("&"):""}function b(e=0,i=100,n="round"){return Math[n](Math.random()*(i-e)+e)}function ne(e=10){const i="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let n="",t=e;const l=i.length;for(;t--;)n+=i[Math.random()*l|0];return n}function te(){const e=b(0,1);return[!0,!1][e]}function re(e){if(!Array.isArray(e))return e;for(let i=e.length-1;i>0;i--){const n=Math.floor(Math.random()*(i+1)),t=e[i];e[i]=e[n],e[n]=t}return e}function le(){const e=b(0,p.length-1);return p[e]}function ae(e){return/^1[3456789]\d{9}$/.test(String(e))}function se(e){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(e)}function ce(e){return/https?:\/\/[\w-]+(\.[\w-]+){1,2}(\/[\w-]{3,6}){0,2}(\?[\w_]{4,6}=[\w_]{4,6}(&[\w_]{4,6}=[\w_]{4,6}){0,2})?/.test(e)}function Me(e){const i=/^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,n=/^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/;return i.test(e)||n.test(e)}function de(e){return/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(e)}function w(){return process.env.NODE_ENV}const ue=w();function k(e){return process.env.NODE_ENV===e}const fe=k("development"),ke=k("test"),he=k("production");o.LocalStorage=F,o.SessionStorage=Q,o.capitalize=J,o.checkIsDark=f,o.checkIsMobile=W,o.checkRuntimeEnv=k,o.clipboard=c,o.ellipsis=Z,o.extractNumber=q,o.extractQueryInfo=ee,o.formatAmount=j,o.getDataType=S,o.getExtension=$,o.getExtensionFromMimeType=g,o.getMimeType=A,o.getPrefersColorScheme=V,o.getQuery=ie,o.getRuntimeEnv=w,o.getUserAgent=s,o.hasKey=u,o.isAndroid=O,o.isBaidu=E,o.isBankCard=de,o.isBrowser=M,o.isDark=U,o.isDesktop=_,o.isDevRuntime=fe,o.isEmail=se,o.isIOS=H,o.isIdCard=Me,o.isLight=R,o.isMob=ae,o.isMobile=C,o.isObject=T,o.isProdRuntime=he,o.isQQ=N,o.isQQBrowser=x,o.isQzone=X,o.isServer=G,o.isTestRuntime=ke,o.isUniApp=v,o.isUrl=ce,o.isWeibo=I,o.isWeixin=y,o.loadRes=Y,o.mobileDevicesRegExp=L,o.parseQuery=K,o.randomBoolean=te,o.randomNumber=b,o.randomString=ne,o.randomUserAgent=le,o.runtimeEnv=ue,o.shuffle=re,o.sleep=D,o.stringifyQuery=oe,o.userAgents=p,o.watchResize=B,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}); | ||
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@withtypes/mime")):typeof define=="function"&&define.amd?define(["exports","@withtypes/mime"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.Utils={},o["@withtypes/mime"]))})(this,function(o,a){"use strict";var he=Object.defineProperty;var ke=(o,a,M)=>a in o?he(o,a,{enumerable:!0,configurable:!0,writable:!0,value:M}):o[a]=M;var h=(o,a,M)=>(ke(o,typeof a!="symbol"?a+"":a,M),M);const M={isSupported:typeof navigator>"u"?!1:Boolean(navigator.clipboard),async copy(e){if(!this.isSupported)return!1;const i=e.innerText||e.value;return await this.write(i)},async cut(e){return!this.isSupported||!await this.copy(e)?!1:(e.value="",!0)},async read(){return this.isSupported?await navigator.clipboard.readText():""},async write(e){return this.isSupported?(await navigator.clipboard.writeText(e),!0):!1}};function s(){return typeof window<"u"?navigator.userAgent.toLowerCase():""}const k=["Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36","Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36","Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36","Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36","Mozilla/5.0 (Linux; U; Android 8.0.0; zh-CN; MHA-AL00 Build/HUAWEIMHA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.1.4.994 Mobile Safari/537.36","Mozilla/5.0 (Linux; Android 8.1; EML-AL00 Build/HUAWEIEML-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.143 Crosswalk/24.53.595.0 XWEB/358 MMWEBSDK/23 Mobile Safari/537.36 MicroMessenger/6.7.2.1340(0x2607023A) NetType/4G Language/zh_CN","Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/044207 Mobile Safari/537.36 MicroMessenger/6.7.3.1340(0x26070332) NetType/4G Language/zh_CN Process/tools","Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13","MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","Mozilla/5.0 (Linux; Android 7.1.1; MI 6 Build/NMF26X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/043807 Mobile Safari/537.36 MicroMessenger/6.6.1.1220(0x26060135) NetType/WIFI Language/zh_CN","Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043632 Safari/537.36 MicroMessenger/6.6.1.1220(0x26060135) NetType/WIFI Language/zh_CN","Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1","Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1","Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1","Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.3; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4","Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (Windows NT 6.1; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/603.2.5 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.5","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/58.0.3029.110 Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 OPR/45.0.2552.888","Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/603.2.5 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.5","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36","Mozilla/5.0 (iPad; CPU OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.0 Mobile/14F89 Safari/602.1","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36 OPR/45.0.2552.812","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0; Trident/5.0)","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Trident/5.0)","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0","Mozilla/5.0 (iPad; CPU OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1","Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36","Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7","Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko","Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36","Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"],c=typeof window<"u",C=!c,K=/iPhone|phone|android|iPod|pad|iPad/i;function b(){return c?K.test(s()):!1}function _(){return c?!b():!1}const O=/Android/i.test(s()),v=/iPhone|iPod|iPad|iOS/i.test(s()),H=/uni-app|html5plus/.test(s()),y=/MicroMessenger/i.test(s()),x=/\sQQ|mqqbrowser|qzone|qqbrowser/i.test(s()),N=/mqqbrowser|qqbrowser/i.test(s()),X=/qzone\/.*_qz_([\d.]+)/i.test(s()),I=/(weibo).*weibo__([\d.]+)/i.test(s()),E=/(baiduboxapp)\/([\d.]+)/i.test(s());function B(e,{immediate:i}={immediate:!0}){c&&(i&&window.addEventListener("load",e,!1),window.addEventListener("orientationchange"in window?"orientationchange":"resize",e,!1))}function p(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function W(e){return p(e)==="object"}function u(e,i){return W(e)?Object.prototype.hasOwnProperty.call(e,i):!1}const S={};class P{constructor(i){h(this,"data");this.data={};const n=u(S,i);this.data=n?S[i].data:{},n||(S[i]=this)}get length(){return Object.keys(this.data).length}clear(){this.data={}}getItem(i){return u(this.data,i)?this.data[i]:null}setItem(i,n){this.data[i]=n}removeItem(i){u(this.data,i)&&delete this.data[i]}key(i){const n=Object.keys(this.data);return i>n.length?null:n[i]}}class L{constructor(i,n){h(this,"prefix");h(this,"storage");this.prefix=i,this.storage=c?window[n]:new P(i)}get(i){const n=this.storage.getItem(`${this.prefix}-${i}`);if(!n)return n;try{return n==="true"?!0:n==="false"?!1:n==="null"?null:n==="undefined"?void 0:JSON.parse(n)}catch{return n}}set(i,n){try{const l=p(n)==="string"?n:JSON.stringify(n);this.storage.setItem(`${this.prefix}-${i}`,l)}catch(t){console.log(t)}}remove(i){this.storage.removeItem(`${this.prefix}-${i}`)}clear(){this.list().forEach(n=>{this.remove(n)})}count(){return this.list().length}list(){if(!this.prefix)return[];const i=[],n=this.storage.length;for(let t=0;t<n;t++){const l=this.storage.key(t);l!=null&&l.startsWith(this.prefix)&&i.push(l.replace(`${this.prefix}-`,""))}return i}}class F extends L{constructor(i){super(i,"localStorage")}}class Q extends L{constructor(i){super(i,"sessionStorage")}}function z(){return c?window.matchMedia("(prefers-color-scheme: dark)").matches:!1}function A(){return c?window.matchMedia("(prefers-color-scheme: light)").matches:!1}function U(){if(z())return"dark";if(A())return"light"}function R(e){return new Promise(i=>{setTimeout(()=>{i()},e)})}function g(e){return e.startsWith("data")&&e.includes("base64")?e.split(",")[0].replace(/data:(.*);base64/,"$1"):a.getType(e)||""}function w(e){return a.getExtension(e)||""}function V(e){const i=g(e);return w(i)}function D(e,i=!1){return e=e?String(e):"",e=e.replace(/[^\d]/g,""),e&&!i&&(e=parseInt(e)),String(e)}function $(e){if(e=String(e),!e)return"0.00";const i=e.split("."),n=i[0],t=i[1];return i.length===1?`${n}.00`:t.length===1?`${e}0`:Number(e).toFixed(2)}function q(e,i){return String(e).length>i?String(e).slice(0,i)+"…":String(e)}function j([e,...i]){return e?(e==null?void 0:e.toUpperCase())+i.join("").toLowerCase():""}function Z({type:e,id:i,resource:n}){return new Promise((t,l)=>{if(!c||document.querySelector(i)){l();return}function d(r){r.addEventListener("load",t),r.addEventListener("error",l),r.addEventListener("abort",l)}switch(e){case"js":{const r=document.createElement("script");r.async=!0,r.src=n,d(r),document.head.appendChild(r);break}case"css":{const r=document.createElement("link");r.id=i,r.rel="stylesheet",r.href=n,d(r),document.head.appendChild(r);break}case"style":{const r=document.createElement("style");r.id=i,d(r),document.head.appendChild(r),r.appendChild(document.createTextNode(n));break}}})}function m(e){let i="";if(c){const{search:t}=window.location;i=t}if(typeof e=="string"&&e.startsWith("http")){const t=e.indexOf("?");i=t===-1?"":e.slice(t)}if(i.includes("#")){const t=i.indexOf("#");i=i.slice(0,t)}if(!i.length)return{};const n={};return i.slice(1).split("&").forEach(t=>{const[l,d]=t.split("=");n[l]=decodeURIComponent(d)}),n}function J(e){const i=m(e),n={};return Object.keys(i).forEach(l=>{l!=="path"&&(n[l]=i[l])}),{path:i.path||"",params:n}}function Y(e,i){return m(i)[e]||""}function ee(e){return W(e)?Object.keys(e).map(i=>`${i}=${encodeURIComponent(String(e[i]))}`).join("&"):""}function T(e=0,i=100,n="round"){return Math[n](Math.random()*(i-e)+e)}function ie(e=10){const i="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let n="",t=e;const l=i.length;for(;t--;)n+=i[Math.random()*l|0];return n}function oe(){const e=T(0,1);return[!0,!1][e]}function ne(e){if(!Array.isArray(e))return e;for(let i=e.length-1;i>0;i--){const n=Math.floor(Math.random()*(i+1)),t=e[i];e[i]=e[n],e[n]=t}return e}function te(){const e=T(0,k.length-1);return k[e]}function re(e){return/^1[3456789]\d{9}$/.test(String(e))}function le(e){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(e)}function ae(e){return/https?:\/\/[\w-]+(\.[\w-]+){1,2}(\/[\w-]{3,6}){0,2}(\?[\w_]{4,6}=[\w_]{4,6}(&[\w_]{4,6}=[\w_]{4,6}){0,2})?/.test(e)}function se(e){const i=/^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,n=/^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/;return i.test(e)||n.test(e)}function ce(e){return/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(e)}function G(){return process.env.NODE_ENV}const Me=G();function f(e){return process.env.NODE_ENV===e}const de=f("development"),ue=f("test"),fe=f("production");o.LocalStorage=F,o.SessionStorage=Q,o.capitalize=j,o.checkRuntimeEnv=f,o.clipboard=M,o.ellipsis=q,o.extractNumber=D,o.extractQueryInfo=J,o.formatAmount=$,o.getDataType=p,o.getExtension=V,o.getExtensionFromMimeType=w,o.getMimeType=g,o.getPrefersColorScheme=U,o.getQuery=Y,o.getRuntimeEnv=G,o.getUserAgent=s,o.hasKey=u,o.isAndroid=O,o.isBaidu=E,o.isBankCard=ce,o.isBrowser=c,o.isDark=z,o.isDesktop=_,o.isDevRuntime=de,o.isEmail=le,o.isIOS=v,o.isIdCard=se,o.isLight=A,o.isMob=re,o.isMobile=b,o.isObject=W,o.isProdRuntime=fe,o.isQQ=x,o.isQQBrowser=N,o.isQzone=X,o.isServer=C,o.isTestRuntime=ue,o.isUniApp=H,o.isUrl=ae,o.isWeibo=I,o.isWeixin=y,o.loadRes=Z,o.mobileDevicesRegExp=K,o.parseQuery=m,o.randomBoolean=oe,o.randomNumber=T,o.randomString=ie,o.randomUserAgent=te,o.runtimeEnv=Me,o.shuffle=ne,o.sleep=R,o.stringifyQuery=ee,o.userAgents=k,o.watchResize=B,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}); |
{ | ||
"name": "@bassist/utils", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Opinionated collection of common JavaScript / TypeScript utils by @chengpeiquan .", | ||
@@ -5,0 +5,0 @@ "author": "chengpeiquan <chengpeiquan@chengpeiquan.com>", |
@@ -111,16 +111,12 @@ /** | ||
*/ | ||
export declare function checkIsDark(): boolean; | ||
export declare function isDark(): boolean; | ||
/** | ||
* @category appearance | ||
*/ | ||
export declare const isDark: boolean; | ||
export declare function isLight(): boolean; | ||
/** | ||
* @category appearance | ||
*/ | ||
export declare const isLight: boolean; | ||
export declare function getPrefersColorScheme(): PrefersColorScheme | undefined; | ||
/** | ||
* @category appearance | ||
*/ | ||
export declare function getPrefersColorScheme(): PrefersColorScheme; | ||
/** | ||
* The actual type of the data | ||
@@ -170,14 +166,10 @@ * | ||
*/ | ||
export declare function checkIsMobile(): boolean; | ||
export declare function isMobile(): boolean; | ||
/** | ||
* @category device | ||
*/ | ||
export declare const isMobile: boolean; | ||
export declare function isDesktop(): boolean; | ||
/** | ||
* @category device | ||
*/ | ||
export declare const isDesktop: boolean; | ||
/** | ||
* @category device | ||
*/ | ||
export declare const isAndroid: boolean; | ||
@@ -184,0 +176,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69523
1047