UNPKG

@madup-inc/utils

Version:
3 lines (2 loc) 3.77 kB
var e=e=>e?Number(e).toLocaleString("ko-KR",{maximumSignificantDigits:10}):"0",t=e=>e?"number"==typeof e?e:Number(String(e).replace(/,/gi,"")):0,n=(e,t)=>{const n=e.find(e=>{if(2!==e.length)throw Error("item array should have 2 length");return"function"==typeof e[0]?e[0]():e[0]}),o=n?n[1]:t;return"function"==typeof o?o():o},o=(...e)=>{const t=e.reduce((e,t)=>{if(!t)return e;if("boolean"==typeof t)throw Error("Boolean type is not acceptable");return"string"==typeof t?e+" "+t:e+Object.entries(t).reduce((e,[t,n])=>e+(n?" "+t:""),"")},"");return t?t.trim():void 0},r=e=>{if(!e)return!1;const t=e.replace(/-/gi,"").split("").map(function(e){return parseInt(e,10)});if(10===t.length){const e=[1,3,7,1,3,7,1,3,5];let n=0;return e.forEach(function(e,o){n+=e*t[o]}),n+=parseInt(String(e[8]*t[8]/10),10),Math.floor(t[9])===(10-n%10)%10}return!1},i=()=>(65536*(1+Math.random())|0).toString(16),c=e=>null==e,a=e=>!c(e),s=(e={})=>Object.entries(e).map(([e,t])=>{if(c(t))return;let n=t;return Array.isArray(t)&&(n=t.join(",")),e+"="+encodeURIComponent(n)}).filter(a).join("&"),p=e=>{const t={},n=e.indexOf("?")+1;return e.slice(n).replace(/([^(?|#)=&]+)(=([^&]*))?/g,(e,n,o,r)=>{t[n]=decodeURIComponent(r)}),t},u=e=>{const t=e.userAgent.toLowerCase();return"Netscape"===e.appName&&-1!==t.indexOf("trident")||-1!==t.indexOf("msie")},d=(e,t=window.document.cookie)=>{const n=t.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return n?decodeURIComponent(n[1]):void 0},l=(e,t=decodeURIComponent)=>{const n={};return e.split(";").map(e=>e.trim()).forEach(e=>{const[o,r]=e.split("=");n[o]=t(r)}),n};function m(){return(m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var f=(e,t,n={},o=encodeURIComponent)=>{const r=m({path:"/"},n);n.expires instanceof Date&&(r.expires=n.expires.toUTCString());let i=o(e)+"="+o(t);for(const e in r){const t=r[e];t&&(i+="; "+e,!0!==t&&(i+="="+t))}return i},g=(e,t,n)=>{window.document.cookie=f(e,t,n)},h=(e,t={})=>{window.document.cookie=f(e,"",m({},t,{"max-age":-1}))},w=(e,t)=>e.some(e=>"string"==typeof e?e===t:"function"==typeof e?e(t):e.test(t));const y=(e,t)=>e.some(e=>"function"==typeof e?e(t):Number.isNaN(e)?Number.isNaN(t):e===t);function b(e,t){return 2===arguments.length?y(e,t):t=>y(e,t)}var x=(e,t=!0)=>{const n=["B","KB","MB","GB"],o=(e,r=0)=>{const i=n[r];return e<1024?`${Math.floor(100*e)/100}${t?i:i.toLowerCase()}`:o(e/1024,r+1)};return o(e)},C=e=>w(e,window.location.pathname),v=e=>{const t=e.lastIndexOf(".");return t<0?{name:e,ext:""}:{name:e.slice(0,t),ext:e.slice(t+1)}},N=(e,t)=>{const n=document.createElement("a");n.href=e,n.setAttribute("download",t),document.body.appendChild(n),n.click(),document.body.removeChild(n)},O=(e,t)=>{const n=window.URL.createObjectURL(new Blob([e]));N(n,t)},E=e=>new Promise(t=>{const n=document.getElementsByTagName("head")[0],o=document.createElement("script");o.type="text/javascript",o.onload=()=>{t(void 0)},o.src=e,n.appendChild(o)}),I=e=>e.replace(/[a-z|0-9][A-Z][a-z|0-9]/g,e=>e[0]+"-"+e.slice(1).toLowerCase()),R=e=>e.replace(/_([a-zA-Z])/g,e=>e[1].toUpperCase()),U=(...e)=>{const t=o(...e);return t?I(t):t};export{I as camelToKabab,o as classNames,U as clsNms,h as deleteCookie,O as downloadData,N as downloadFile,x as fileSizeUnit,d as getCookie,u as isIE,c as isNil,a as isNotNil,E as loadJs,b as matched,n as oneOf,l as parseCookie,v as parseFilename,p as parseSearchParams,C as pathMatched,i as randomStr,f as serializeCookie,s as serializeSearchParams,g as setCookie,R as snakeToCamel,w as strMatched,e as toComma,t as toNumber,r as validateBiznum}; //# sourceMappingURL=index.modern.js.map