@machinerd/js-module 0.0.8 → 0.0.10
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.mjs +1 -1
- package/package.json +4 -3
package/dist/util/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunk-Bmb41Sf3.cjs`);let t=require(`js-cookie`);t=e.t(t);let n=require(`query-string`);n=e.t(n);let r=require(`dayjs`);r=e.t(r),require(`dayjs/locale/ko.js`);let i=require(`dayjs/plugin/relativeTime.js`);i=e.t(i);let a=require(`lodash-es`),o=require(`nanoid`),s=require(`
|
|
1
|
+
const e=require(`../chunk-Bmb41Sf3.cjs`);let t=require(`js-cookie`);t=e.t(t);let n=require(`query-string`);n=e.t(n);let r=require(`dayjs`);r=e.t(r),require(`dayjs/locale/ko.js`);let i=require(`dayjs/plugin/relativeTime.js`);i=e.t(i);let a=require(`lodash-es`),o=require(`nanoid`),s=require(`slug`);s=e.t(s);let c=require(`google-libphonenumber`);c=e.t(c);const l=c.default.PhoneNumberFormat,u=c.default.PhoneNumberUtil.getInstance();r.default.extend(i.default),s.default.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`}),s.default.setLocale(`en`);const d=(e,t=`YYYY-MM-DD`,n=`en`)=>{let i=(0,r.default)(e).locale(n);return(0,r.default)().diff(i,`hour`)<12?i.fromNow():i.format(t)},f=e=>t.default.get(e),p=(e,n,r)=>t.default.set(e,n,r),m=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:r,search:i}=window.location,a=n.default.parse(i);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]}),`?${n.default.stringify(o,{encode:!0})}${r}`},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)=>{let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${(0,s.default)(e)}`)}),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=()=>(0,o.customAlphabet)(`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=(0,a.uniq)([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)=>(0,a.intersection)(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]};exports.appendSearchPath=z,exports.calcPageCount=h,exports.clearQueryByKey=V,exports.clearSearchPath=B,exports.comparePriorityAsc=D,exports.composeKey=U,exports.deleteAllSearchHistory=N,exports.deleteSearchHistory=M,exports.displayDatetime=d,exports.existLeastOne=L,exports.formatBytes=W,exports.formatI18nNumber=x,exports.genNanoID=O,exports.getCookie=f,exports.getFileExtension=K,exports.getFilename=G,exports.getFirstLocationAddress=J,exports.getFullAddress=Y,exports.getI18nKey=H,exports.getI18nValue=E,exports.getI18nValues=T,exports.getModelName=w,exports.getSearchHistory=A,exports.insertSearchHistory=j,exports.isSearchPage=R,exports.link=m,exports.loadExLib=y,exports.parsePath=q,exports.parseQuery=P,exports.printNanoID=k,exports.productSlugify=C,exports.randomNum=v,exports.recomposeI18nNumber=b,exports.selectItemByWeight=X,exports.setCookies=p,exports.shuffle=g,exports.slugify=S,exports.withoutProperties=I,exports.withoutProperty=F;
|
package/dist/util/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"js-cookie";import t from"query-string";import n from"dayjs";import"dayjs/locale/ko.js";import r from"dayjs/plugin/relativeTime.js";import{intersection as i,uniq as a}from"lodash-es";import{customAlphabet as o}from"nanoid";import s from"
|
|
1
|
+
import e from"js-cookie";import t from"query-string";import n from"dayjs";import"dayjs/locale/ko.js";import r from"dayjs/plugin/relativeTime.js";import{intersection as i,uniq as a}from"lodash-es";import{customAlphabet as o}from"nanoid";import s from"slug";import c from"google-libphonenumber";const l=c.PhoneNumberFormat,u=c.PhoneNumberUtil.getInstance();n.extend(r),s.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`}),s.setLocale(`en`);const d=(e,t=`YYYY-MM-DD`,r=`en`)=>{let i=n(e).locale(r);return n().diff(i,`hour`)<12?i.fromNow():i.format(t)},f=t=>e.get(t),p=(t,n,r)=>e.set(t,n,r),m=(e,n=[])=>{if(typeof window>`u`)return``;let{hash:r,search:i}=window.location,a=t.parse(i);Object.keys(e).forEach(t=>{e[t]?a[t]=e[t]:delete a[t]});let o={...a};return Object.keys(a).forEach(e=>{n.includes(e)&&delete o[e]}),`?${t.stringify(o,{encode:!0})}${r}`},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)=>{let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${s(e)}`)}),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=()=>o(`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=a([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)=>i(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.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
"keywords": [],
|
|
26
26
|
"author": "KOMACHINE",
|
|
27
27
|
"license": "MIT",
|
|
28
|
-
"packageManager": "pnpm@10.
|
|
28
|
+
"packageManager": "pnpm@10.25.0",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typed/node": "^6.7.0",
|
|
31
31
|
"@types/google-libphonenumber": "^7.4.30",
|
|
32
32
|
"@types/js-cookie": "^3.0.6",
|
|
33
33
|
"@types/lodash-es": "^4.17.12",
|
|
34
34
|
"@types/node": "^24.10.1",
|
|
35
|
+
"@types/slug": "^5.0.9",
|
|
35
36
|
"tsdown": "0.17.0-beta.5",
|
|
36
37
|
"typescript": "^5.9.3"
|
|
37
38
|
},
|
|
@@ -42,6 +43,6 @@
|
|
|
42
43
|
"lodash-es": "^4.17.21",
|
|
43
44
|
"nanoid": "^5.1.6",
|
|
44
45
|
"query-string": "^9.3.1",
|
|
45
|
-
"
|
|
46
|
+
"slug": "^11.0.1"
|
|
46
47
|
}
|
|
47
48
|
}
|