@machinerd/js-module 0.0.6 → 0.0.7

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(`js-cookie`);u=s(u);let d=require(`lodash-es`),f=require(`nanoid`),p=require(`query-string`);p=s(p);let m=require(`slugify`);m=s(m);let h=require(`google-libphonenumber`);h=s(h);const g=h.default.PhoneNumberFormat,_=h.default.PhoneNumberUtil.getInstance();c.default.extend(l.default);const v=(e,t=`YYYY-MM-DD`,n=`en`)=>{let r=(0,c.default)(e).locale(n);return(0,c.default)().diff(r,`hour`)<12?r.fromNow():r.format(t)},y=e=>u.default.get(e),b=(e,t,n)=>u.default.set(e,t,n),x=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=p.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]}),`?${p.default.stringify(a,{encode:!0})}${n}`},S=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},C=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},w=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},ee=(e,t,n=1)=>{let r=[],i=w(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]},T=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()},E=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,D=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=g.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=_.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?_.format(i,g.NATIONAL):_.format(i,n)}catch{return E(r||`en`,e,t?.callingCode)}},O=(e,...t)=>{m.default.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${(0,m.default)(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},k=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]),O(e.id,...t)},A=e=>{let t=e;return t.length>0?t[0].trim():``},j=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(N);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``},M=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(N);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},N=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,P=()=>(0,f.customAlphabet)(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),F=e=>{for(let t=0;t<e;t++)console.log(P())},I=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),L=e=>{let t=(0,d.uniq)([e,...I()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},R=e=>{let t=I();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},z=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},B=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},V=(e,t)=>{let{[t]:n,...r}=e;return r},H=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),U=(e,t)=>(0,d.intersection)(e,t).length>0,W=e=>e.endsWith(`/search`),G=e=>W(e)?e:`${e}/search`.replace(`//`,`/`),K=e=>e.replace(`/search`,``).replace(`//`,`/`),q=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},J=e=>e.split(`:`).pop()?.split(`.`).pop(),Y=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function X(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 Z=e=>e.split(`.`).slice(0,-1).join(`.`),Q=e=>e.split(`.`).pop(),te=(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},ne=(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=j(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()},re=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=G,exports.calcPageCount=S,exports.clearQueryByKey=q,exports.clearSearchPath=K,exports.comparePriorityAsc=N,exports.composeKey=Y,exports.deleteAllSearchHistory=z,exports.deleteSearchHistory=R,exports.displayDatetime=v,exports.existLeastOne=U,exports.formatBytes=X,exports.formatI18nNumber=D,exports.genNanoID=P,exports.getCookie=y,exports.getFileExtension=Q,exports.getFilename=Z,exports.getFirstLocationAddress=ne,exports.getFullAddress=$,exports.getI18nKey=J,exports.getI18nValue=M,exports.getI18nValues=j,exports.getModelName=A,exports.getSearchHistory=I,exports.insertSearchHistory=L,exports.isSearchPage=W,exports.link=x,exports.loadExLib=T,exports.parsePath=te,exports.parseQuery=B,exports.printNanoID=F,exports.productSlugify=k,exports.randomNum=ee,exports.recomposeI18nNumber=E,exports.selectItemByWeight=re,exports.setCookies=b,exports.shuffle=C,exports.slugify=O,exports.withoutProperties=H,exports.withoutProperty=V;
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.js`);let l=require(`dayjs/plugin/relativeTime.js`);l=s(l);let u=require(`js-cookie`);u=s(u);let d=require(`lodash-es`),f=require(`nanoid`),p=require(`query-string`);p=s(p);let m=require(`slugify`);m=s(m);let h=require(`google-libphonenumber`);h=s(h);const g=h.default.PhoneNumberFormat,_=h.default.PhoneNumberUtil.getInstance();c.default.extend(l.default);const v=(e,t=`YYYY-MM-DD`,n=`en`)=>{let r=(0,c.default)(e).locale(n);return(0,c.default)().diff(r,`hour`)<12?r.fromNow():r.format(t)},y=e=>u.default.get(e),b=(e,t,n)=>u.default.set(e,t,n),x=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=p.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]}),`?${p.default.stringify(a,{encode:!0})}${n}`},S=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},C=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},w=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},ee=(e,t,n=1)=>{let r=[],i=w(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]},T=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()},E=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,D=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=g.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=_.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?_.format(i,g.NATIONAL):_.format(i,n)}catch{return E(r||`en`,e,t?.callingCode)}},O=(e,...t)=>{m.default.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${(0,m.default)(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},k=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]),O(e.id,...t)},A=e=>{let t=e;return t.length>0?t[0].trim():``},j=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(N);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``},M=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(N);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},N=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,P=()=>(0,f.customAlphabet)(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),F=e=>{for(let t=0;t<e;t++)console.log(P())},I=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),L=e=>{let t=(0,d.uniq)([e,...I()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},R=e=>{let t=I();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},z=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},B=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},V=(e,t)=>{let{[t]:n,...r}=e;return r},H=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),U=(e,t)=>(0,d.intersection)(e,t).length>0,W=e=>e.endsWith(`/search`),G=e=>W(e)?e:`${e}/search`.replace(`//`,`/`),K=e=>e.replace(`/search`,``).replace(`//`,`/`),q=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},J=e=>e.split(`:`).pop()?.split(`.`).pop(),Y=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function X(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 Z=e=>e.split(`.`).slice(0,-1).join(`.`),Q=e=>e.split(`.`).pop(),te=(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},ne=(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=j(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()},re=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=G,exports.calcPageCount=S,exports.clearQueryByKey=q,exports.clearSearchPath=K,exports.comparePriorityAsc=N,exports.composeKey=Y,exports.deleteAllSearchHistory=z,exports.deleteSearchHistory=R,exports.displayDatetime=v,exports.existLeastOne=U,exports.formatBytes=X,exports.formatI18nNumber=D,exports.genNanoID=P,exports.getCookie=y,exports.getFileExtension=Q,exports.getFilename=Z,exports.getFirstLocationAddress=ne,exports.getFullAddress=$,exports.getI18nKey=J,exports.getI18nValue=M,exports.getI18nValues=j,exports.getModelName=A,exports.getSearchHistory=I,exports.insertSearchHistory=L,exports.isSearchPage=W,exports.link=x,exports.loadExLib=T,exports.parsePath=te,exports.parseQuery=B,exports.printNanoID=F,exports.productSlugify=k,exports.randomNum=ee,exports.recomposeI18nNumber=E,exports.selectItemByWeight=re,exports.setCookies=b,exports.shuffle=C,exports.slugify=O,exports.withoutProperties=H,exports.withoutProperty=V;
@@ -1,5 +1,5 @@
1
1
  //#region src/util/common.d.ts
2
- declare const displayDatetime: (date: string, format?: string, locale?: string) => any;
2
+ declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
3
3
  declare const getCookie: (key: string) => string | undefined;
4
4
  declare const setCookies: (key: string, value: string, options?: Cookies.CookieAttributes) => string | undefined;
5
5
  declare const link: (param: Record<string, string>, deleteKeys?: string[]) => string;
@@ -1,7 +1,7 @@
1
- import "dayjs/locale/ko";
1
+ import "dayjs/locale/ko.js";
2
2
 
3
3
  //#region src/util/common.d.ts
4
- declare const displayDatetime: (date: string, format?: string, locale?: string) => any;
4
+ declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
5
5
  declare const getCookie: (key: string) => string | undefined;
6
6
  declare const setCookies: (key: string, value: string, options?: Cookies.CookieAttributes) => string | undefined;
7
7
  declare const link: (param: Record<string, string>, deleteKeys?: string[]) => string;
@@ -1 +1 @@
1
- import e from"dayjs";import"dayjs/locale/ko";import t from"dayjs/plugin/relativeTime";import n from"js-cookie";import{intersection as r,uniq as i}from"lodash-es";import{customAlphabet as a}from"nanoid";import o from"query-string";import s from"slugify";import c from"google-libphonenumber";const l=c.PhoneNumberFormat,u=c.PhoneNumberUtil.getInstance();e.extend(t);const d=(t,n=`YYYY-MM-DD`,r=`en`)=>{let i=e(t).locale(r);return e().diff(i,`hour`)<12?i.fromNow():i.format(n)},f=e=>n.get(e),p=(e,t,r)=>n.set(e,t,r),m=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=o.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]}),`?${o.stringify(a,{encode:!0})}${n}`},h=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},g=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},_=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},v=(e,t,n=1)=>{let r=[],i=_(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]},y=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()},b=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,x=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=l.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=u.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?u.format(i,l.NATIONAL):u.format(i,n)}catch{return b(r||`en`,e,t?.callingCode)}},S=(e,...t)=>{s.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${s(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},C=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]),S(e.id,...t)},w=e=>{let t=e;return t.length>0?t[0].trim():``},T=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(D);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``},E=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(D);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},D=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,O=()=>a(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),k=e=>{for(let t=0;t<e;t++)console.log(O())},A=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),j=e=>{let t=i([e,...A()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},M=e=>{let t=A();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},N=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},P=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},F=(e,t)=>{let{[t]:n,...r}=e;return r},I=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),L=(e,t)=>r(e,t).length>0,R=e=>e.endsWith(`/search`),z=e=>R(e)?e:`${e}/search`.replace(`//`,`/`),B=e=>e.replace(`/search`,``).replace(`//`,`/`),V=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},H=e=>e.split(`:`).pop()?.split(`.`).pop(),U=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function W(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 G=e=>e.split(`.`).slice(0,-1).join(`.`),K=e=>e.split(`.`).pop(),q=(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},J=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?Y(e,n.i18n):`-`},Y=(e=`en`,t)=>{if(t.length===0)return``;let n=T(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()},X=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{z as appendSearchPath,h as calcPageCount,V as clearQueryByKey,B as clearSearchPath,D as comparePriorityAsc,U as composeKey,N as deleteAllSearchHistory,M as deleteSearchHistory,d as displayDatetime,L as existLeastOne,W as formatBytes,x as formatI18nNumber,O as genNanoID,f as getCookie,K as getFileExtension,G as getFilename,J as getFirstLocationAddress,Y as getFullAddress,H as getI18nKey,E as getI18nValue,T as getI18nValues,w as getModelName,A as getSearchHistory,j as insertSearchHistory,R as isSearchPage,m as link,y as loadExLib,q as parsePath,P as parseQuery,k as printNanoID,C as productSlugify,v as randomNum,b as recomposeI18nNumber,X as selectItemByWeight,p as setCookies,g as shuffle,S as slugify,I as withoutProperties,F as withoutProperty};
1
+ import e from"dayjs";import"dayjs/locale/ko.js";import t from"dayjs/plugin/relativeTime.js";import n from"js-cookie";import{intersection as r,uniq as i}from"lodash-es";import{customAlphabet as a}from"nanoid";import o from"query-string";import s from"slugify";import c from"google-libphonenumber";const l=c.PhoneNumberFormat,u=c.PhoneNumberUtil.getInstance();e.extend(t);const d=(t,n=`YYYY-MM-DD`,r=`en`)=>{let i=e(t).locale(r);return e().diff(i,`hour`)<12?i.fromNow():i.format(n)},f=e=>n.get(e),p=(e,t,r)=>n.set(e,t,r),m=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=o.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]}),`?${o.stringify(a,{encode:!0})}${n}`},h=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},g=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},_=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},v=(e,t,n=1)=>{let r=[],i=_(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]},y=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()},b=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,x=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=l.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=u.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?u.format(i,l.NATIONAL):u.format(i,n)}catch{return b(r||`en`,e,t?.callingCode)}},S=(e,...t)=>{s.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${s(e,{lower:!0,trim:!0,locale:`en`,strict:!0})}`)}),n},C=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]),S(e.id,...t)},w=e=>{let t=e;return t.length>0?t[0].trim():``},T=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(D);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``},E=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(D);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},D=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,O=()=>a(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),k=e=>{for(let t=0;t<e;t++)console.log(O())},A=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),j=e=>{let t=i([e,...A()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},M=e=>{let t=A();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},N=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},P=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},F=(e,t)=>{let{[t]:n,...r}=e;return r},I=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),L=(e,t)=>r(e,t).length>0,R=e=>e.endsWith(`/search`),z=e=>R(e)?e:`${e}/search`.replace(`//`,`/`),B=e=>e.replace(`/search`,``).replace(`//`,`/`),V=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},H=e=>e.split(`:`).pop()?.split(`.`).pop(),U=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function W(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 G=e=>e.split(`.`).slice(0,-1).join(`.`),K=e=>e.split(`.`).pop(),q=(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},J=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?Y(e,n.i18n):`-`},Y=(e=`en`,t)=>{if(t.length===0)return``;let n=T(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()},X=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{z as appendSearchPath,h as calcPageCount,V as clearQueryByKey,B as clearSearchPath,D as comparePriorityAsc,U as composeKey,N as deleteAllSearchHistory,M as deleteSearchHistory,d as displayDatetime,L as existLeastOne,W as formatBytes,x as formatI18nNumber,O as genNanoID,f as getCookie,K as getFileExtension,G as getFilename,J as getFirstLocationAddress,Y as getFullAddress,H as getI18nKey,E as getI18nValue,T as getI18nValues,w as getModelName,A as getSearchHistory,j as insertSearchHistory,R as isSearchPage,m as link,y as loadExLib,q as parsePath,P as parseQuery,k as printNanoID,C as productSlugify,v as randomNum,b as recomposeI18nNumber,X as selectItemByWeight,p as setCookies,g as shuffle,S as slugify,I as withoutProperties,F as withoutProperty};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinerd/js-module",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/index.mjs",