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