@madup-inc/utils
Version:
Common utils of LEVER
3 lines (2 loc) • 3.6 kB
JavaScript
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=function(){const e=[].slice.call(arguments).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 e?e.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},c=()=>(65536*(1+Math.random())|0).toString(16),i=e=>null==e,a=e=>!i(e),s=(e={})=>Object.entries(e).map(([e,t])=>{if(i(t))return;let n=t;return Array.isArray(t)&&(n=t.join(",")),e+"="+encodeURIComponent(n)}).filter(a).join("&"),u=e=>{const t={},n=e.indexOf("?")+1;return e.slice(n).replace(/([^(?|#)=&]+)(=([^&]*))?/g,(e,n,o,r)=>{t[n]=decodeURIComponent(r)}),t},l=e=>{const t=e.userAgent.toLowerCase();return"Netscape"===e.appName&&-1!==t.indexOf("trident")||-1!==t.indexOf("msie")},p=(e,t=window.document.cookie)=>{const n=t.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return n?decodeURIComponent(n[1]):void 0},d=(e,t=decodeURIComponent)=>{const n={};return e.split(";").map(e=>e.trim()).forEach(e=>{const[o,r]=e.split("=");n[o]=t(r)}),n},m=(e,t,n={},o=encodeURIComponent)=>{const r={path:"/",...n};n.expires instanceof Date&&(r.expires=n.expires.toUTCString());let c=o(e)+"="+o(t);for(const e in r){const t=r[e];t&&(c+="; "+e,!0!==t&&(c+="="+t))}return c},f=(e,t,n)=>{window.document.cookie=m(e,t,n)},g=(e,t={})=>{window.document.cookie=m(e,"",{...t,"max-age":-1})},h=(e,t)=>e.some(e=>"string"==typeof e?e===t:"function"==typeof e?e(t):e.test(t));const w=(e,t)=>e.some(e=>"function"==typeof e?e(t):Number.isNaN(e)?Number.isNaN(t):e===t);function y(e,t){return 2===arguments.length?w(e,t):t=>w(e,t)}var b=(e,t=!0)=>{const n=["B","KB","MB","GB"],o=(e,r=0)=>{const c=n[r];return e<1024?`${Math.floor(100*e)/100}${t?c:c.toLowerCase()}`:o(e/1024,r+1)};return o(e)},x=e=>h(e,window.location.pathname),C=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)},E=(e,t)=>{const n=window.URL.createObjectURL(new Blob([e]));N(n,t)},I=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)}),R=e=>e.replace(/[a-z|0-9][A-Z][a-z|0-9]/g,e=>e[0]+"-"+e.slice(1).toLowerCase()),U=e=>e.replace(/_([a-zA-Z])/g,e=>e[1].toUpperCase()),v=function(){const e=o(...[].slice.call(arguments));return e?R(e):e};export{R as camelToKabab,o as classNames,v as clsNms,g as deleteCookie,E as downloadData,N as downloadFile,b as fileSizeUnit,p as getCookie,l as isIE,i as isNil,a as isNotNil,I as loadJs,y as matched,n as oneOf,d as parseCookie,C as parseFilename,u as parseSearchParams,x as pathMatched,c as randomStr,m as serializeCookie,s as serializeSearchParams,f as setCookie,U as snakeToCamel,h as strMatched,e as toComma,t as toNumber,r as validateBiznum};
//# sourceMappingURL=index.module.js.map