@machinerd/js-module 0.0.4 → 0.0.5
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.cts +1 -3
- package/dist/util/index.d.mts +1 -3
- 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(`js-cookie`);c=s(c);let l=require(`lodash-es`),u=require(`nanoid`),d=require(`query-string`);d=s(d);let f=require(`slugify`);f=s(f);let p=require(`google-libphonenumber`);p=s(p);const m=p.default.PhoneNumberFormat,h=p.default.PhoneNumberUtil.getInstance(),g=e=>c.default.get(e),_=(e,t,n)=>c.default.set(e,t,n),v=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,i=d.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]}),`?${d.default.stringify(a,{encode:!0})}${n}`},y=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},b=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},x=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},S=(e,t,n=1)=>{let r=[],i=x(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]},C=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=m.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=h.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?h.format(i,m.NATIONAL):h.format(i,n)}catch{return w(r||`en`,e,t?.callingCode)}},E=(e,...t)=>{f.default.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${(0,f.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,u.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,l.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,l.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()},ee=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=y,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=g,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=v,exports.loadExLib=C,exports.parsePath=Z,exports.parseQuery=R,exports.printNanoID=N,exports.productSlugify=D,exports.randomNum=S,exports.recomposeI18nNumber=w,exports.selectItemByWeight=ee,exports.setCookies=_,exports.shuffle=b,exports.slugify=E,exports.withoutProperties=B,exports.withoutProperty=z;
|
package/dist/util/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { PhoneNumberFormat } from "google-libphonenumber";
|
|
2
|
-
|
|
3
1
|
//#region src/util/common.d.ts
|
|
4
2
|
declare const getCookie: (key: string) => string | undefined;
|
|
5
3
|
declare const setCookies: (key: string, value: string, options?: Cookies.CookieAttributes) => string | undefined;
|
|
@@ -16,7 +14,7 @@ interface Country {
|
|
|
16
14
|
interface I18nNumberProps<C extends Country = Country> {
|
|
17
15
|
phone?: string | null;
|
|
18
16
|
country?: C | null;
|
|
19
|
-
format?:
|
|
17
|
+
format?: number;
|
|
20
18
|
locale?: string | null;
|
|
21
19
|
}
|
|
22
20
|
declare const formatI18nNumber: ({
|
package/dist/util/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { PhoneNumberFormat } from "google-libphonenumber";
|
|
2
|
-
|
|
3
1
|
//#region src/util/common.d.ts
|
|
4
2
|
declare const getCookie: (key: string) => string | undefined;
|
|
5
3
|
declare const setCookies: (key: string, value: string, options?: Cookies.CookieAttributes) => string | undefined;
|
|
@@ -16,7 +14,7 @@ interface Country {
|
|
|
16
14
|
interface I18nNumberProps<C extends Country = Country> {
|
|
17
15
|
phone?: string | null;
|
|
18
16
|
country?: C | null;
|
|
19
|
-
format?:
|
|
17
|
+
format?: number;
|
|
20
18
|
locale?: string | null;
|
|
21
19
|
}
|
|
22
20
|
declare const formatI18nNumber: ({
|
package/dist/util/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"js-cookie";import{intersection as t,uniq as n}from"lodash-es";import{customAlphabet as r}from"nanoid";import i from"query-string";import a from"slugify";import o from"google-libphonenumber";const s=o.PhoneNumberFormat,c=o.PhoneNumberUtil.getInstance(),l=t=>e.get(t),u=(t,n,r)=>e.set(t,n,r),d=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:n,search:r}=window.location,a=i.parse(r);Object.keys(e).forEach(t=>{e[t]?a[t]=e[t]:delete a[t]});let o={...a};return Object.keys(a).forEach(e=>{t.includes(e)&&delete o[e]}),`?${i.stringify(o,{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:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=s.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=c.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?c.format(i,s.NATIONAL):c.format(i,n)}catch{return _(r||`en`,e,t?.callingCode)}},y=(e,...t)=>{a.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`});let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${a(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=()=>r(`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=n([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,n)=>t(e,n).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};
|