@machinerd/js-module 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`dayjs`);c=s(c),require(`dayjs/locale/ko`);let l=require(`dayjs/plugin/relativeTime`);l=s(l);let u=require(`google-libphonenumber`),d=require(`js-cookie`);d=s(d);let f=require(`lodash-es`),p=require(`nanoid`),m=require(`query-string`);m=s(m);let h=require(`slugify`);h=s(h);const g=u.PhoneNumberUtil.getInstance();c.default.extend(l.default);const _=e=>d.default.get(e),v=(e,t,n)=>d.default.set(e,t,n),y=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=m.default.parse(r);Object.keys(e).forEach(t=>{e[t]?i[t]=e[t]:delete i[t]});let a={...i};return Object.keys(i).forEach(e=>{t.includes(e)&&delete a[e]}),`?${m.default.stringify(a,{encode:!0})}${n}`},b=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},x=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},S=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},C=(e,t,n=1)=>{let r=[],i=S(e,t);for(;r.length<n;){let t=Math.ceil(e),n=Math.floor(i.length),a=Math.floor(Math.random()*(n-t))+t,o=i.splice(a,1);r.push(o[0])}return[...r]},ee=e=>{let t=document.getElementById(`naverMapLib`);if(!t){let t=document.createElement(`script`);t.src=`https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=ecs1pyoo9b`,t.id=`naverMapLib`,document.body.appendChild(t),t.onload=()=>{e&&e()}}t&&e&&e()},w=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,T=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=u.PhoneNumberFormat.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=g.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?g.format(i,u.PhoneNumberFormat.NATIONAL):g.format(i,n)}catch{return w(r||`en`,e,t?.callingCode)}},E=(e,...t)=>{h.default.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${(0,h.default)(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},D=e=>{let t=[];e.i18n?.forEach(e=>{e.locale===`en`&&e.name&&t.push(e.name)});let n=e.series?.i18n.find(e=>e.locale===`en`);return n?.name&&t.push(n.name.toLowerCase()),e.stockNo&&t.push(e.stockNo[0]),E(e.id,...t)},O=e=>{let t=e;return t.length>0?t[0].trim():``},k=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(j);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}for(let e of r){let t=e[n];if(!(Array.isArray(t)&&t.length===0)&&t)return t}return``},A=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(j);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}let i=``;for(let e of r){let t=e[n];if(t){i=String(t);break}}return i},j=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,M=()=>(0,p.customAlphabet)(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),N=e=>{for(let t=0;t<e;t++)console.log(M())},P=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),F=e=>{let t=(0,f.uniq)([e,...P()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},I=e=>{let t=P();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},L=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},R=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},z=(e,t)=>{let{[t]:n,...r}=e;return r},B=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),V=(e,t)=>(0,f.intersection)(e,t).length>0,H=e=>e.endsWith(`/search`),U=e=>H(e)?e:`${e}/search`.replace(`//`,`/`),W=e=>e.replace(`/search`,``).replace(`//`,`/`),G=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},K=e=>e.split(`:`).pop()?.split(`.`).pop(),q=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function J(e,t=0){if(e==0)return`0 Bytes`;let n=1024,r=t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**+a).toFixed(r))+` `+i[a]}const Y=e=>e.split(`.`).slice(0,-1).join(`.`),X=e=>e.split(`.`).pop(),Z=(e,t)=>{let n={directory:``,filename:``,extension:``,filenameWithoutExtension:``},r=e.lastIndexOf(`/`),i=r>=0?e.substring(r+1):e,a=i.lastIndexOf(`.`),o=a>0?i.substring(a+1):``,s=a>0?i.substring(0,a):i;if(n.filename=i,n.extension=o,n.filenameWithoutExtension=s,e.startsWith(`http`)){let r=t?`/static/`:`/media/`,i=e.indexOf(r);if(i!==-1){let t=e.substring(i+r.length),a=t.lastIndexOf(`/`);return n.directory=a===-1?``:t.substring(0,a),n}}return n.directory=r===-1?``:e.substring(0,r),n},Q=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?$(e,n.i18n):`-`},$=(e=`en`,t)=>{if(t.length===0)return``;let n=k(e,t,`address1`)?.replace(`대한민국`,``)||``,r=t.find(t=>t.locale===e)?.address2,i=[n];return e===`ko`?i.push(r):i.unshift(r),i.filter(Boolean).join(`, `).trim()},te=e=>{let t=0;for(let n of e)t+=n.weight;let n=Math.random()*t,r=0;for(let t of e)if(r+=t.weight,n<r)return t;return e[e.length-1]};exports.appendSearchPath=U,exports.calcPageCount=b,exports.clearQueryByKey=G,exports.clearSearchPath=W,exports.comparePriorityAsc=j,exports.composeKey=q,exports.deleteAllSearchHistory=L,exports.deleteSearchHistory=I,exports.existLeastOne=V,exports.formatBytes=J,exports.formatI18nNumber=T,exports.genNanoID=M,exports.getCookie=_,exports.getFileExtension=X,exports.getFilename=Y,exports.getFirstLocationAddress=Q,exports.getFullAddress=$,exports.getI18nKey=K,exports.getI18nValue=A,exports.getI18nValues=k,exports.getModelName=O,exports.getSearchHistory=P,exports.insertSearchHistory=F,exports.isSearchPage=H,exports.link=y,exports.loadExLib=ee,exports.parsePath=Z,exports.parseQuery=R,exports.printNanoID=N,exports.productSlugify=D,exports.randomNum=C,exports.recomposeI18nNumber=w,exports.selectItemByWeight=te,exports.setCookies=v,exports.shuffle=x,exports.slugify=E,exports.withoutProperties=B,exports.withoutProperty=z;
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`dayjs`);c=s(c);let l=require(`dayjs/plugin/relativeTime`);l=s(l);let u=require(`google-libphonenumber`),d=require(`js-cookie`);d=s(d);let f=require(`lodash-es`),p=require(`nanoid`),m=require(`query-string`);m=s(m);let h=require(`slugify`);h=s(h);const g=u.PhoneNumberUtil.getInstance();c.default.extend(l.default);const _=e=>d.default.get(e),v=(e,t,n)=>d.default.set(e,t,n),y=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=m.default.parse(r);Object.keys(e).forEach(t=>{e[t]?i[t]=e[t]:delete i[t]});let a={...i};return Object.keys(i).forEach(e=>{t.includes(e)&&delete a[e]}),`?${m.default.stringify(a,{encode:!0})}${n}`},b=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},x=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},S=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},C=(e,t,n=1)=>{let r=[],i=S(e,t);for(;r.length<n;){let t=Math.ceil(e),n=Math.floor(i.length),a=Math.floor(Math.random()*(n-t))+t,o=i.splice(a,1);r.push(o[0])}return[...r]},ee=e=>{let t=document.getElementById(`naverMapLib`);if(!t){let t=document.createElement(`script`);t.src=`https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=ecs1pyoo9b`,t.id=`naverMapLib`,document.body.appendChild(t),t.onload=()=>{e&&e()}}t&&e&&e()},w=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,T=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=u.PhoneNumberFormat.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=g.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?g.format(i,u.PhoneNumberFormat.NATIONAL):g.format(i,n)}catch{return w(r||`en`,e,t?.callingCode)}},E=(e,...t)=>{h.default.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${(0,h.default)(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},D=e=>{let t=[];e.i18n?.forEach(e=>{e.locale===`en`&&e.name&&t.push(e.name)});let n=e.series?.i18n.find(e=>e.locale===`en`);return n?.name&&t.push(n.name.toLowerCase()),e.stockNo&&t.push(e.stockNo[0]),E(e.id,...t)},O=e=>{let t=e;return t.length>0?t[0].trim():``},k=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(j);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}for(let e of r){let t=e[n];if(!(Array.isArray(t)&&t.length===0)&&t)return t}return``},A=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(j);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}let i=``;for(let e of r){let t=e[n];if(t){i=String(t);break}}return i},j=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,M=()=>(0,p.customAlphabet)(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),N=e=>{for(let t=0;t<e;t++)console.log(M())},P=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),F=e=>{let t=(0,f.uniq)([e,...P()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},I=e=>{let t=P();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},L=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},R=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},z=(e,t)=>{let{[t]:n,...r}=e;return r},B=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),V=(e,t)=>(0,f.intersection)(e,t).length>0,H=e=>e.endsWith(`/search`),U=e=>H(e)?e:`${e}/search`.replace(`//`,`/`),W=e=>e.replace(`/search`,``).replace(`//`,`/`),G=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},K=e=>e.split(`:`).pop()?.split(`.`).pop(),q=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function J(e,t=0){if(e==0)return`0 Bytes`;let n=1024,r=t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**+a).toFixed(r))+` `+i[a]}const Y=e=>e.split(`.`).slice(0,-1).join(`.`),X=e=>e.split(`.`).pop(),Z=(e,t)=>{let n={directory:``,filename:``,extension:``,filenameWithoutExtension:``},r=e.lastIndexOf(`/`),i=r>=0?e.substring(r+1):e,a=i.lastIndexOf(`.`),o=a>0?i.substring(a+1):``,s=a>0?i.substring(0,a):i;if(n.filename=i,n.extension=o,n.filenameWithoutExtension=s,e.startsWith(`http`)){let r=t?`/static/`:`/media/`,i=e.indexOf(r);if(i!==-1){let t=e.substring(i+r.length),a=t.lastIndexOf(`/`);return n.directory=a===-1?``:t.substring(0,a),n}}return n.directory=r===-1?``:e.substring(0,r),n},Q=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?$(e,n.i18n):`-`},$=(e=`en`,t)=>{if(t.length===0)return``;let n=k(e,t,`address1`)?.replace(`대한민국`,``)||``,r=t.find(t=>t.locale===e)?.address2,i=[n];return e===`ko`?i.push(r):i.unshift(r),i.filter(Boolean).join(`, `).trim()},te=e=>{let t=0;for(let n of e)t+=n.weight;let n=Math.random()*t,r=0;for(let t of e)if(r+=t.weight,n<r)return t;return e[e.length-1]};exports.appendSearchPath=U,exports.calcPageCount=b,exports.clearQueryByKey=G,exports.clearSearchPath=W,exports.comparePriorityAsc=j,exports.composeKey=q,exports.deleteAllSearchHistory=L,exports.deleteSearchHistory=I,exports.existLeastOne=V,exports.formatBytes=J,exports.formatI18nNumber=T,exports.genNanoID=M,exports.getCookie=_,exports.getFileExtension=X,exports.getFilename=Y,exports.getFirstLocationAddress=Q,exports.getFullAddress=$,exports.getI18nKey=K,exports.getI18nValue=A,exports.getI18nValues=k,exports.getModelName=O,exports.getSearchHistory=P,exports.insertSearchHistory=F,exports.isSearchPage=H,exports.link=y,exports.loadExLib=ee,exports.parsePath=Z,exports.parseQuery=R,exports.printNanoID=N,exports.productSlugify=D,exports.randomNum=C,exports.recomposeI18nNumber=w,exports.selectItemByWeight=te,exports.setCookies=v,exports.shuffle=x,exports.slugify=E,exports.withoutProperties=B,exports.withoutProperty=z;
@@ -1,4 +1,3 @@
1
- import "dayjs/locale/ko";
2
1
  import { PhoneNumberFormat } from "google-libphonenumber";
3
2
 
4
3
  //#region src/util/common.d.ts
@@ -1 +1 @@
1
- import e from"dayjs";import"dayjs/locale/ko";import t from"dayjs/plugin/relativeTime";import{PhoneNumberFormat as n,PhoneNumberUtil as r}from"google-libphonenumber";import i from"js-cookie";import{intersection as a,uniq as o}from"lodash-es";import{customAlphabet as s}from"nanoid";import c from"query-string";import l from"slugify";const u=r.getInstance();e.extend(t);const d=e=>i.get(e),f=(e,t,n)=>i.set(e,t,n),p=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=c.parse(r);Object.keys(e).forEach(t=>{e[t]?i[t]=e[t]:delete i[t]});let a={...i};return Object.keys(i).forEach(e=>{t.includes(e)&&delete a[e]}),`?${c.stringify(a,{encode:!0})}${n}`},m=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},h=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},g=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},_=(e,t,n=1)=>{let r=[],i=g(e,t);for(;r.length<n;){let t=Math.ceil(e),n=Math.floor(i.length),a=Math.floor(Math.random()*(n-t))+t,o=i.splice(a,1);r.push(o[0])}return[...r]},v=e=>{let t=document.getElementById(`naverMapLib`);if(!t){let t=document.createElement(`script`);t.src=`https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=ecs1pyoo9b`,t.id=`naverMapLib`,document.body.appendChild(t),t.onload=()=>{e&&e()}}t&&e&&e()},y=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,b=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:r=n.INTERNATIONAL,locale:i})=>{if(!e||e===`-`)return`-`;try{let a=u.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),o=a.getCountryCode();return i===`ko`&&t?.alpha2Code===`KR`&&o===82?u.format(a,n.NATIONAL):u.format(a,r)}catch{return y(i||`en`,e,t?.callingCode)}},x=(e,...t)=>{l.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${l(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},S=e=>{let t=[];e.i18n?.forEach(e=>{e.locale===`en`&&e.name&&t.push(e.name)});let n=e.series?.i18n.find(e=>e.locale===`en`);return n?.name&&t.push(n.name.toLowerCase()),e.stockNo&&t.push(e.stockNo[0]),x(e.id,...t)},C=e=>{let t=e;return t.length>0?t[0].trim():``},w=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(E);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}for(let e of r){let t=e[n];if(!(Array.isArray(t)&&t.length===0)&&t)return t}return``},T=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(E);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}let i=``;for(let e of r){let t=e[n];if(t){i=String(t);break}}return i},E=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,D=()=>s(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),O=e=>{for(let t=0;t<e;t++)console.log(D())},k=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),A=e=>{let t=o([e,...k()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},j=e=>{let t=k();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},M=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},N=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},P=(e,t)=>{let{[t]:n,...r}=e;return r},F=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),I=(e,t)=>a(e,t).length>0,L=e=>e.endsWith(`/search`),R=e=>L(e)?e:`${e}/search`.replace(`//`,`/`),z=e=>e.replace(`/search`,``).replace(`//`,`/`),B=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},V=e=>e.split(`:`).pop()?.split(`.`).pop(),H=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function U(e,t=0){if(e==0)return`0 Bytes`;let n=1024,r=t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**+a).toFixed(r))+` `+i[a]}const W=e=>e.split(`.`).slice(0,-1).join(`.`),G=e=>e.split(`.`).pop(),K=(e,t)=>{let n={directory:``,filename:``,extension:``,filenameWithoutExtension:``},r=e.lastIndexOf(`/`),i=r>=0?e.substring(r+1):e,a=i.lastIndexOf(`.`),o=a>0?i.substring(a+1):``,s=a>0?i.substring(0,a):i;if(n.filename=i,n.extension=o,n.filenameWithoutExtension=s,e.startsWith(`http`)){let r=t?`/static/`:`/media/`,i=e.indexOf(r);if(i!==-1){let t=e.substring(i+r.length),a=t.lastIndexOf(`/`);return n.directory=a===-1?``:t.substring(0,a),n}}return n.directory=r===-1?``:e.substring(0,r),n},q=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?J(e,n.i18n):`-`},J=(e=`en`,t)=>{if(t.length===0)return``;let n=w(e,t,`address1`)?.replace(`대한민국`,``)||``,r=t.find(t=>t.locale===e)?.address2,i=[n];return e===`ko`?i.push(r):i.unshift(r),i.filter(Boolean).join(`, `).trim()},Y=e=>{let t=0;for(let n of e)t+=n.weight;let n=Math.random()*t,r=0;for(let t of e)if(r+=t.weight,n<r)return t;return e[e.length-1]};export{R as appendSearchPath,m as calcPageCount,B as clearQueryByKey,z as clearSearchPath,E as comparePriorityAsc,H as composeKey,M as deleteAllSearchHistory,j as deleteSearchHistory,I as existLeastOne,U as formatBytes,b as formatI18nNumber,D as genNanoID,d as getCookie,G as getFileExtension,W as getFilename,q as getFirstLocationAddress,J as getFullAddress,V as getI18nKey,T as getI18nValue,w as getI18nValues,C as getModelName,k as getSearchHistory,A as insertSearchHistory,L as isSearchPage,p as link,v as loadExLib,K as parsePath,N as parseQuery,O as printNanoID,S as productSlugify,_ as randomNum,y as recomposeI18nNumber,Y as selectItemByWeight,f as setCookies,h as shuffle,x as slugify,F as withoutProperties,P as withoutProperty};
1
+ import e from"dayjs";import t from"dayjs/plugin/relativeTime";import{PhoneNumberFormat as n,PhoneNumberUtil as r}from"google-libphonenumber";import i from"js-cookie";import{intersection as a,uniq as o}from"lodash-es";import{customAlphabet as s}from"nanoid";import c from"query-string";import l from"slugify";const u=r.getInstance();e.extend(t);const d=e=>i.get(e),f=(e,t,n)=>i.set(e,t,n),p=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=c.parse(r);Object.keys(e).forEach(t=>{e[t]?i[t]=e[t]:delete i[t]});let a={...i};return Object.keys(i).forEach(e=>{t.includes(e)&&delete a[e]}),`?${c.stringify(a,{encode:!0})}${n}`},m=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},h=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},g=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},_=(e,t,n=1)=>{let r=[],i=g(e,t);for(;r.length<n;){let t=Math.ceil(e),n=Math.floor(i.length),a=Math.floor(Math.random()*(n-t))+t,o=i.splice(a,1);r.push(o[0])}return[...r]},v=e=>{let t=document.getElementById(`naverMapLib`);if(!t){let t=document.createElement(`script`);t.src=`https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=ecs1pyoo9b`,t.id=`naverMapLib`,document.body.appendChild(t),t.onload=()=>{e&&e()}}t&&e&&e()},y=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,b=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:r=n.INTERNATIONAL,locale:i})=>{if(!e||e===`-`)return`-`;try{let a=u.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),o=a.getCountryCode();return i===`ko`&&t?.alpha2Code===`KR`&&o===82?u.format(a,n.NATIONAL):u.format(a,r)}catch{return y(i||`en`,e,t?.callingCode)}},x=(e,...t)=>{l.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${l(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},S=e=>{let t=[];e.i18n?.forEach(e=>{e.locale===`en`&&e.name&&t.push(e.name)});let n=e.series?.i18n.find(e=>e.locale===`en`);return n?.name&&t.push(n.name.toLowerCase()),e.stockNo&&t.push(e.stockNo[0]),x(e.id,...t)},C=e=>{let t=e;return t.length>0?t[0].trim():``},w=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(E);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}for(let e of r){let t=e[n];if(!(Array.isArray(t)&&t.length===0)&&t)return t}return``},T=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(E);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}let i=``;for(let e of r){let t=e[n];if(t){i=String(t);break}}return i},E=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,D=()=>s(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),O=e=>{for(let t=0;t<e;t++)console.log(D())},k=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),A=e=>{let t=o([e,...k()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},j=e=>{let t=k();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},M=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},N=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},P=(e,t)=>{let{[t]:n,...r}=e;return r},F=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),I=(e,t)=>a(e,t).length>0,L=e=>e.endsWith(`/search`),R=e=>L(e)?e:`${e}/search`.replace(`//`,`/`),z=e=>e.replace(`/search`,``).replace(`//`,`/`),B=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},V=e=>e.split(`:`).pop()?.split(`.`).pop(),H=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function U(e,t=0){if(e==0)return`0 Bytes`;let n=1024,r=t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**+a).toFixed(r))+` `+i[a]}const W=e=>e.split(`.`).slice(0,-1).join(`.`),G=e=>e.split(`.`).pop(),K=(e,t)=>{let n={directory:``,filename:``,extension:``,filenameWithoutExtension:``},r=e.lastIndexOf(`/`),i=r>=0?e.substring(r+1):e,a=i.lastIndexOf(`.`),o=a>0?i.substring(a+1):``,s=a>0?i.substring(0,a):i;if(n.filename=i,n.extension=o,n.filenameWithoutExtension=s,e.startsWith(`http`)){let r=t?`/static/`:`/media/`,i=e.indexOf(r);if(i!==-1){let t=e.substring(i+r.length),a=t.lastIndexOf(`/`);return n.directory=a===-1?``:t.substring(0,a),n}}return n.directory=r===-1?``:e.substring(0,r),n},q=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?J(e,n.i18n):`-`},J=(e=`en`,t)=>{if(t.length===0)return``;let n=w(e,t,`address1`)?.replace(`대한민국`,``)||``,r=t.find(t=>t.locale===e)?.address2,i=[n];return e===`ko`?i.push(r):i.unshift(r),i.filter(Boolean).join(`, `).trim()},Y=e=>{let t=0;for(let n of e)t+=n.weight;let n=Math.random()*t,r=0;for(let t of e)if(r+=t.weight,n<r)return t;return e[e.length-1]};export{R as appendSearchPath,m as calcPageCount,B as clearQueryByKey,z as clearSearchPath,E as comparePriorityAsc,H as composeKey,M as deleteAllSearchHistory,j as deleteSearchHistory,I as existLeastOne,U as formatBytes,b as formatI18nNumber,D as genNanoID,d as getCookie,G as getFileExtension,W as getFilename,q as getFirstLocationAddress,J as getFullAddress,V as getI18nKey,T as getI18nValue,w as getI18nValues,C as getModelName,k as getSearchHistory,A as insertSearchHistory,L as isSearchPage,p as link,v as loadExLib,K as parsePath,N as parseQuery,O as printNanoID,S as productSlugify,_ as randomNum,y as recomposeI18nNumber,Y as selectItemByWeight,f as setCookies,h as shuffle,x as slugify,F as withoutProperties,P as withoutProperty};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinerd/js-module",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/index.mjs",