qsu 1.6.3 → 1.6.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/format.js +1 -1
- package/dist/string.js +1 -1
- package/dist/verify.d.ts +1 -1
- package/package.json +6 -6
package/dist/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{basename as
|
|
1
|
+
import{basename as r,extname as t,win32 as e}from"path";export function numberFormat(r){return new Intl.NumberFormat("en-US",{roundingPriority:"morePrecision"}).format(r)}export function fileName(n,o=!1){return n?-1===n.indexOf("/")?o?e.basename(n):e.basename(n,t(n)):o?r(n):r(n,t(n)):""}export function fileSize(r,t=2){if(!r||0===r||r<0)return"0 Bytes";const e=Math.floor(Math.log(r)/Math.log(1024));return`${parseFloat((r/1024**e).toFixed(t<0?0:t))} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][e]}`}export function fileExt(r){if(-1===r.indexOf("."))return"Unknown";const t=r.trim().toLowerCase().split(".");return t.length>0?t[t.length-1]:"Unknown"}export function duration(r,t){const{useShortString:e=!1,useSpace:n=!0,withZeroValue:o=!1,separator:i=" "}={...t},a=[{name:"Millisecond",short:"ms",divider:1e3},{name:"Second",short:"S",divider:60},{name:"Minute",short:"M",divider:60},{name:"Hour",short:"H",divider:24},{name:"Day",short:"D",divider:31}],s=[];let u=r;for(let r=0;r<a.length;r+=1){const t=a[r];let i=u%t.divider;r===a.length-1?i=Math.trunc(u):u=(u-i)/t.divider,(o||!o&&0!==i)&&s.push(`${i}${n?" ":""}${e?t.short:`${t.name}${i<2?"":"s"}`}`)}return s.reverse().join(i)}export function safeJSONParse(r,t={}){if(!r)return t;if(Array.isArray(r)||"object"==typeof r)try{return JSON.parse(JSON.stringify(r))}catch(r){return t}try{return JSON.parse(r)}catch(r){return t}}export function safeParseInt(r,t=0,e=10){if(!r||r.toString().length<1)return t;try{return parseInt(r.toString().split(".")[0],e)}catch(r){return t}}
|
package/dist/string.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contains as t}from"./verify.js";import{numRandom as e}from"./math.js";export function trim(t){return"string"==typeof t||t?t.trim().replace(/\s{2,}/g," "):null}export function removeSpecialChar(t,e){return t?t.replace(new RegExp(`[^a-zA-Z가-힣ㄱ-ㅎㅏ-ㅣ0-9-ヿ㐀-䶿一-鿿豈-ヲ-゚${e??""}]`,"gi"),""):""}export function replaceBetween(t,e,r,n=""){if(!t)return"";const o=/[.*+?^${}()|[\]\\]/g,i=o.test(e)?`\\${e}`:e,l=o.test(r)?`\\${r}`:r;return t.replace(new RegExp(`${i}.*?${l}`,"g"),n)}export function removeNewLine(t,e=""){return t?t.replace(/(\r\n|\n|\r)/gm,e).trim():""}export function capitalizeFirst(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}export function capitalizeEverySentence(t,e){if(!t)return"";const r=e||".",n=t.split(r);let o,i="";for(let t=0,e=n.length;t<e;t+=1){o=[...n[t]];for(let e=0,r=o.length;e<r;e+=1)if(/[a-zA-Z]/.test(n[t][e])){o[e]=n[t][e].toUpperCase();break}i+=`${o.join("")}${t<e-1?r:""}`}return i}export function capitalizeEachWords(e,r){if(!e)return"";const n=e.trim().toLowerCase().split(" ");for(let e=0,o=n.length;e<o;e+=1)r&&t(n[e],["in","on","the","at","and","or","of","for","to","that","a","by","it","is","as","are","were","was","nor","an"],!0)||(n[e]=capitalizeFirst(n[e]));return capitalizeFirst(n.join(" "))}export function strCount(t,e){if(!t||!e)return 0;let r=0,n=t.indexOf(e);for(;n>-1;)r+=1,n=t.indexOf(e,n+=e.length);return r}export function strShuffle(t){return t?[...t].sort((()=>Math.random()-.5)).join(""):""}export function strRandom(t,e){const r=`abcdefghijklmnopqrstuvwxyz0123456789${e}`,n=r.length;let o,i="";for(let e=0;e<t;e+=1)o=r.charAt(Math.floor(Math.random()*n)),o=Math.random()<.5?o.toUpperCase():o,i+=o;return i}export function strBlindRandom(t,r,n="*"){if(!t)return"";let o=t,i=0,l=0,a=0;const c=o.length;for(;i<r&&a<c;)l=e(0,c),/[a-zA-Z가-힣]/.test(o.substring(l,l+1))&&(o=`${o.substring(0,l+1)}${n}${o.substring(l+2)}`,i+=1),a+=1;return o}export function truncate(t,e,r=""){if(!t)return"";let n=t;return t.length>e&&(n=t.substring(0,e)+r),n}export function truncateExpect(t,e,r="."){if(!t)return"";const n=t.slice(-1)===r,o=t.split(r),i=o.length;let l="",a=0;for(let t=0;t<i&&a<e;t+=1)l+=`${o[t]}${t!==i-1||n?r:""}`,a+=o[t].length+r.length;return l}export function split(t,...e){if(!t)return[];const r=e.length>0&&"object"==typeof e[0]?e[0]:e,n=r.length;let o="",i="";for(let t=0;t<n;t+=1){const e=r[t];e.length>1?i+=`${i.length<1?"":"|"}${e.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/]/g,"\\]").replace(/\?/g,"\\?").replace(/\./g,"\\.").replace(/\{/g,"\\{").replace(/}/g,"\\}").replace(/\+/g,"\\+")}`:o+="-"===e||"["===e||"]"===e?`\\${e}`:e}return o.length<1&&i.length<1?[t]:(o.length>0&&(o=`[${o}]`,i.length>0&&(i=`|${i}`)),t.split(new RegExp(`${o}${i}+`,"gi")))}export function strToAscii(t){const e=[];for(let r=0;r<t.length;r+=1)e.push(t.charCodeAt(r));return e}export function strUnique(t){return t?[...new Set(t)].join(""):""}export function urlJoin(...t){if(!t)return"";const e=t.length;let r="",n=0;for(let o=0;o<e;o+=1)null!==t[o]&&void 0!==t[o]&&(0===n||t[o].startsWith("/")||t[o].startsWith("?")||t[o].startsWith("&")?r+=t[o]:r+=`/${t[o]}`,n+=1);return r.replace(/\/$/g,"")}
|
|
1
|
+
import{contains as t}from"./verify.js";import{numRandom as e}from"./math.js";export function trim(t){return"string"==typeof t||t?t.trim().replace(/\s{2,}/g," "):null}export function removeSpecialChar(t,e){return t?t.replace(new RegExp(`[^a-zA-Z가-힣ㄱ-ㅎㅏ-ㅣ0-9-ヿ㐀-䶿一-鿿豈-ヲ-゚${e??""}]`,"gi"),""):""}export function replaceBetween(t,e,r,n=""){if(!t)return"";const o=/[.*+?^${}()|[\]\\]/g,i=o.test(e)?`\\${e}`:e,l=o.test(r)?`\\${r}`:r;return t.replace(new RegExp(`${i}.*?${l}`,"g"),n)}export function removeNewLine(t,e=""){return t?t.replace(/(\r\n|\n|\r)/gm,e).trim():""}export function capitalizeFirst(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}export function capitalizeEverySentence(t,e){if(!t)return"";const r=e||".",n=t.split(r);let o,i="";for(let t=0,e=n.length;t<e;t+=1){o=[...n[t]];for(let e=0,r=o.length;e<r;e+=1)if(/[a-zA-Z]/.test(n[t][e])){o[e]=n[t][e].toUpperCase();break}i+=`${o.join("")}${t<e-1?r:""}`}return i}export function capitalizeEachWords(e,r){if(!e)return"";const n=e.trim().toLowerCase().split(" ");for(let e=0,o=n.length;e<o;e+=1)r&&t(n[e],["in","on","the","at","and","or","of","for","to","that","a","by","it","is","as","are","were","was","nor","an"],!0)||(n[e]=capitalizeFirst(n[e]));return capitalizeFirst(n.join(" "))}export function strCount(t,e){if(!t||!e)return 0;let r=0,n=t.indexOf(e);for(;n>-1;)r+=1,n=t.indexOf(e,n+=e.length);return r}export function strShuffle(t){return t?[...t].sort((()=>Math.random()-.5)).join(""):""}export function strRandom(t,e){const r=`abcdefghijklmnopqrstuvwxyz0123456789${e}`,n=r.length;let o,i="";for(let e=0;e<t;e+=1)o=r.charAt(Math.floor(Math.random()*n)),o=Math.random()<.5?o.toUpperCase():o,i+=o;return i}export function strBlindRandom(t,r,n="*"){if(!t)return"";let o=t,i=0,l=0,a=0;const c=o.length;for(;i<r&&a<c;)l=e(0,c),/[a-zA-Z가-힣]/.test(o.substring(l,l+1))&&(o=`${o.substring(0,l+1)}${n}${o.substring(l+2)}`,i+=1),a+=1;return o}export function truncate(t,e,r=""){if(!t)return"";let n=t;return t.length>e&&(n=t.substring(0,e)+r),n}export function truncateExpect(t,e,r="."){if(!t)return"";if(t.length<=e)return t;const n=t.slice(-1)===r,o=t.split(r),i=o.length;let l="",a=0;for(let t=0;t<i&&a<e;t+=1)l+=`${o[t]}${t!==i-1||n?r:""}`,a+=o[t].length+r.length;return l}export function split(t,...e){if(!t)return[];const r=e.length>0&&"object"==typeof e[0]?e[0]:e,n=r.length;let o="",i="";for(let t=0;t<n;t+=1){const e=r[t];e.length>1?i+=`${i.length<1?"":"|"}${e.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/]/g,"\\]").replace(/\?/g,"\\?").replace(/\./g,"\\.").replace(/\{/g,"\\{").replace(/}/g,"\\}").replace(/\+/g,"\\+")}`:o+="-"===e||"["===e||"]"===e?`\\${e}`:e}return o.length<1&&i.length<1?[t]:(o.length>0&&(o=`[${o}]`,i.length>0&&(i=`|${i}`)),t.split(new RegExp(`${o}${i}+`,"gi")))}export function strToAscii(t){const e=[];for(let r=0;r<t.length;r+=1)e.push(t.charCodeAt(r));return e}export function strUnique(t){return t?[...new Set(t)].join(""):""}export function urlJoin(...t){if(!t)return"";const e=t.length;let r="",n=0;for(let o=0;o<e;o+=1)null!==t[o]&&void 0!==t[o]&&(0===n||t[o].startsWith("/")||t[o].startsWith("?")||t[o].startsWith("&")?r+=t[o]:r+=`/${t[o]}`,n+=1);return r.replace(/\/$/g,"")}
|
package/dist/verify.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export declare function is2dArray(array: any[]): boolean;
|
|
|
8
8
|
export declare function between(range: [number, number], number: number, inclusive?: boolean): boolean;
|
|
9
9
|
export declare function len(data: any): number;
|
|
10
10
|
export declare function isEmail(email: string): boolean;
|
|
11
|
-
export declare function isTrueMinimumNumberOfTimes(conditions:
|
|
11
|
+
export declare function isTrueMinimumNumberOfTimes(conditions: any[], minimumCount?: number): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qsu",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "QSU is a lightweight and simple module with a variety of built-in utility functions that you can utilize in your NodeJS projects.",
|
|
5
5
|
"author": "CDGet <jooy2.contact@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"file"
|
|
66
66
|
],
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@types/node": "22.
|
|
68
|
+
"@types/node": "22.13.5",
|
|
69
69
|
"@typescript-eslint/eslint-plugin": "7.14.1",
|
|
70
70
|
"@typescript-eslint/parser": "7.14.1",
|
|
71
71
|
"dayjs": "^1.11.13",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"eslint-config-airbnb": "19.0.4",
|
|
74
74
|
"eslint-config-prettier": "9.1.0",
|
|
75
75
|
"eslint-plugin-import": "2.29.1",
|
|
76
|
-
"glob": "^11.0.
|
|
77
|
-
"prettier": "^3.
|
|
76
|
+
"glob": "^11.0.1",
|
|
77
|
+
"prettier": "^3.5.2",
|
|
78
78
|
"terser-glob": "^1.1.0",
|
|
79
|
-
"tsx": "^4.19.
|
|
80
|
-
"typescript": "^5.7.
|
|
79
|
+
"tsx": "^4.19.3",
|
|
80
|
+
"typescript": "^5.7.3"
|
|
81
81
|
}
|
|
82
82
|
}
|