UNPKG

iking-utils-pro

Version:

金合前端工具库

2 lines (1 loc) 2.03 kB
function t(t,e){return Object.prototype.toString.call(t)===`[object ${e}]`}function e(t){return Object.prototype.toString.call(t)}class i{static isJSON(t){try{return!!JSON.parse(t)}catch(t){return!1}}static getTypeLong(t){return e(t)}static getType(t){const i=e(t);return i.substring(8,i.length-1).toLocaleLowerCase()}static isDef(t){return void 0!==t}static isUnDef(t){return!this.isDef(t)}static isObject(e){return null!==e&&t(e,"Object")}static isEmpty(t){return this.isArray(t)||this.isString(t)?0===t.length:t instanceof Map||t instanceof Set?0===t.size:!!this.isObject(t)&&0===Object.keys(t).length}static isDate(e){return t(e,"Date")}static isNull(t){return null===t}static isNullAndUnDef(t){return this.isUnDef(t)&&this.isNull(t)}static isNullOrUnDef(t){return this.isUnDef(t)||this.isNull(t)}static isNumber(e){return t(e,"Number")}static isPromise(e){return t(e,"Promise")&&this.isObject(e)&&this.isFunction(e.then)&&this.isFunction(e.catch)}static isString(e){return t(e,"String")}static isFunction(t){return"function"==typeof t}static isBoolean(e){return t(e,"Boolean")}static isRegExp(e){return t(e,"RegExp")}static isArray(t){return t&&Array.isArray(t)}static isWindow(e){return"undefined"!=typeof window&&t(e,"Window")}static isElement(t){return this.isObject(t)&&!!t.tagName}static isMap(e){return t(e,"Map")}static isServer="undefined"==typeof window;static isClient=!this.isServer;static isUrl(t){return/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/.test(t)}}const s=(t,e)=>t&&e?e.startsWith("http")?e:`${t}${e}`:"",r=t=>{if(!t)return{};const e=new URL(t),i=new URLSearchParams(e.search);return Object.fromEntries(i.entries())},n=(t,e)=>r(t)[e],c=(t,e)=>{const s=/\$\{([^\}]+)\}/g;let r;for(;null!==(r=s.exec(t));){const s=r[1];i.isObject(e)&&e.hasOwnProperty(s)&&(t=t.replace(r[0],String(e[s])))}return t};export{s as assembleUrl,n as getUrlKeyData,r as parseUrl,c as replaceTemplateVar};