qsu 1.12.2 → 1.13.1

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.
@@ -5,11 +5,15 @@ export type NumberValueObject = {
5
5
  export type AnyValueObject = {
6
6
  [key: string]: any;
7
7
  };
8
+ export type DurationUnitName = 'Year' | 'Month' | 'Day' | 'Hour' | 'Minute' | 'Second' | 'Millisecond';
8
9
  export type DurationOptions = {
9
10
  useShortString?: boolean;
10
11
  useSpace?: boolean;
11
12
  withZeroValue?: boolean;
12
13
  separator?: string;
14
+ withMilliSeconds?: boolean;
15
+ maxUnitCount?: number;
16
+ unit?: DurationUnitName;
13
17
  };
14
18
  export interface FileInfo {
15
19
  success: boolean;
@@ -55,3 +59,19 @@ export interface GetUptimeOption {
55
59
  format?: boolean;
56
60
  floor?: boolean;
57
61
  }
62
+ export interface ParsedAddress {
63
+ error: boolean;
64
+ protocol?: string;
65
+ host?: string;
66
+ port?: number;
67
+ user?: string;
68
+ pass?: string;
69
+ }
70
+ export interface SlugOptions {
71
+ separator?: string;
72
+ includeNumbers?: boolean;
73
+ includeSpecial?: boolean;
74
+ uppercase?: boolean;
75
+ includeNonLatin?: boolean;
76
+ baseUrl?: string;
77
+ }
@@ -1 +1 @@
1
- export function duration(e,r){const{useShortString:t=!1,useSpace:i=!0,withZeroValue:n=!1,separator:o=" "}={...r},d=[{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 a=e;for(let e=0;e<d.length;e+=1){const r=d[e];let o=a%r.divider;e===d.length-1?o=Math.trunc(a):a=(a-o)/r.divider,(n||!n&&0!==o)&&s.push(`${o}${i?" ":""}${t?r.short:`${r.name}${o<2?"":"s"}`}`)}return s.reverse().join(o)}
1
+ const e=[{name:"Year",short:"Y",ms:31536e6},{name:"Month",short:"Mo",ms:2592e6},{name:"Day",short:"D",ms:864e5},{name:"Hour",short:"H",ms:36e5},{name:"Minute",short:"M",ms:6e4},{name:"Second",short:"S",ms:1e3},{name:"Millisecond",short:"ms",ms:1}];function t(e,t,n,o){return`${e}${o?" ":""}${n?t.short:`${t.name}${1===e?"":"s"}`}`}export function duration(n,o){const{useShortString:s=!1,useSpace:r=!0,withZeroValue:a=!1,separator:i=" ",withMilliSeconds:m=!1,maxUnitCount:u,unit:l}={...o};if(l){const o=l.toLowerCase().replace(/s$/,""),a=e.find(e=>e.name.toLowerCase()===o);if(a)return t((c=n/a.ms,Number(c.toFixed(6))),a,s,r)}var c;const h=m?e:e.filter(e=>"Millisecond"!==e.name),f=[];let d=n;for(const e of h){const t=Math.floor(d/e.ms);d-=t*e.ms,f.push({value:t,unit:e})}const M=f.findIndex(e=>0!==e.value);if(-1===M)return"";let p=f.slice(M).filter(e=>a||0!==e.value).map(e=>t(e.value,e.unit,s,r));return"number"==typeof u&&u>=0&&(p=p.slice(0,u)),p.join(i)}
@@ -1,3 +1,4 @@
1
1
  export { debounce } from './debounce.js';
2
2
  export { funcTimes } from './funcTimes.js';
3
+ export { logBox } from './logBox.js';
3
4
  export { sleep } from './sleep.js';
@@ -1 +1 @@
1
- export{debounce}from"./debounce.js";export{funcTimes}from"./funcTimes.js";export{sleep}from"./sleep.js";
1
+ export{debounce}from"./debounce.js";export{funcTimes}from"./funcTimes.js";export{logBox}from"./logBox.js";export{sleep}from"./sleep.js";
@@ -0,0 +1 @@
1
+ export declare function logBox(...args: unknown[]): void;
@@ -0,0 +1 @@
1
+ import{inspect as t}from"node:util";const n={tl:"┌",tr:"┐",bl:"└",br:"┘",h:"─",v:"│",lt:"├",rt:"┤",tt:"┬",bt:"┴",x:"┼"};function o(t){return 0===t||t<32||t>=127&&t<160?0:t>=4352&&t<=4447||t>=11904&&t<=12350||t>=12353&&t<=13311||t>=13312&&t<=19903||t>=19968&&t<=40959||t>=40960&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=127744&&t<=129791||t>=131072&&t<=262141?2:1}function r(t){let n=0;for(const r of t)n+=o(r.codePointAt(0));return n}function e(t,n){const o=n-r(t);return o>0?t+" ".repeat(o):t}function s(t,n){const o=n-r(t);if(o<=0)return t;const e=Math.floor(o/2);return" ".repeat(e)+t+" ".repeat(o-e)}export function logBox(...u){const c=Math.max(function(){for(const t of[process.stdout,process.stderr]){const n=t?.columns;if("number"==typeof n&&n>0)return n}const t=Number(process.env.COLUMNS);return Number.isFinite(t)&&t>0?Math.floor(t):80}(),10),l=u.map((t,n)=>String(n)),p=Math.max(r("#"),...l.map(r),1),a=p+2;let f=c-a-3;f<3&&(f=3);const h=f-2,i=(t,o,r)=>t+n.h.repeat(a)+o+n.h.repeat(f)+r,m=i(n.tl,n.tt,n.tr),g=i(n.lt,n.x,n.rt),b=i(n.bl,n.bt,n.br),x=(t,o)=>`${n.v} ${t} ${n.v} ${o} ${n.v}`,v=[m];if(v.push(x(s("#",p),e("value",h))),v.push(g),0===u.length)return v.push(x(s("-",p),e("(no arguments)",h))),v.push(b),void console.log(v.join("\n"));u.forEach((n,r)=>{var c,a;const f=function(t,n){const r=[],e=Math.max(1,n);for(const n of t.split("\n")){if(""===n){r.push("");continue}let t="",s=0;for(const u of n){const n=o(u.codePointAt(0));s+n>e?(r.push(t),t=u,s=n):(t+=u,s+=n)}r.push(t)}return r}((a=h,"string"==typeof(c=n)?c:t(c,{depth:null,breakLength:a,colors:!1,maxArrayLength:null,maxStringLength:null,compact:3})),h);f.forEach((t,n)=>{const o=0===n?s(l[r],p):" ".repeat(p);v.push(x(o,e(t,h)))}),r<u.length-1&&v.push(g)}),v.push(b),console.log(v.join("\n"))}
@@ -1 +1 @@
1
- import{open as r}from"fs/promises";import{createFile as t}from"./createFile.js";export async function createFileWithDummy(e,i){if(!i||i<0)throw new Error("Size is required");try{if(0===i)return await t(e),!0;const a=await r(e,"w");return await a.write(Buffer.alloc(1),0,1,i-1),await a.close(),!0}catch{return!1}}
1
+ import{open as r}from"fs/promises";import{createFile as e}from"./createFile.js";export async function createFileWithDummy(t,i){if(null==i)throw new Error("Size is required");if(i<0)throw new Error("Size must be 0 or greater");try{if(0===i)return await e(t),!0;const o=await r(t,"w");return await o.write(Buffer.alloc(1),0,1,i-1),await o.close(),!0}catch{return!1}}
@@ -1 +1 @@
1
- import{getFileName as e}from"./getFileName.js";import{getFileExtension as t}from"./getFileExtension.js";export function getCopyFileName(o,r){const i=e(o),n=t(o),s=new Set(r);if(!s.has(o))return o;for(let e=1;;e++){const t=`${i} (${e})${n?`.${n}`:""}`;if(!s.has(t))return t}}
1
+ import{getFileName as e}from"./getFileName.js";export function getCopyFileName(t,n){const o=e(t),r=e(t,!0).slice(o.length),i=new Set(n);if(!i.has(t))return t;for(let e=1;;e++){const t=`${o} (${e})${r}`;if(!i.has(t))return t}}
@@ -1 +1 @@
1
- import{posix as t}from"path";import{toPosixFilePath as e}from"./toPosixFilePath.js";export function getFilePathLevel(o){return o?"/"===o?1:e(o.replace(/\\+$/,"")).split(t.sep).length:-1}
1
+ import{posix as t}from"path";import{toPosixFilePath as e}from"./toPosixFilePath.js";export function getFilePathLevel(o){return o?"/"===o?1:e(o.replace(/[\\/]+$/,"")).split(t.sep).length:-1}
@@ -1 +1 @@
1
- import{access as r}from"fs/promises";import{constants as t}from"fs";export async function isFileExists(i){try{return await r(i,t.F_OK),!0}catch{return!1}}
1
+ import{stat as r}from"fs/promises";export async function isFileExists(t){try{return await r(t),!0}catch{return!1}}
@@ -1 +1 @@
1
- import{getFileName as e}from"./getFileName.js";export function isValidFileName(t,i){let s;const l=e(t);return s=i?/(^\s+$)|(^\.+$)|([:/]+)/:/(^\s+$)|(^\.+$)|([<>:"/\\|?*]+)/,!s.test(l)&&l.length<=255}
1
+ import{getFileName as t}from"./getFileName.js";const e=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;export function isValidFileName(i,n){let s;const l=t(i,!0);if(n)s=/(^\s+$)|(^\.+$)|([:/]+)/;else if(s=/(^\s+$)|(^\.+$)|([<>:"/\\|?*]+)/,e.test(l.split(".")[0]))return!1;return!s.test(l)&&l.length<=255}
@@ -1 +1 @@
1
- import{posix as e,win32 as t}from"path";export function toValidFilePath(i,n){if(i?.length<1)return n?"\\":"/";if(n){let e=i;return e=t.normalize(e).replace(/\.$/g,""),e.endsWith("\\")&&e.length>1&&(e=e.replace(/\\+$/,"")),e.endsWith(":")&&(e=`${e}\\`),e.startsWith("\\")||-1!==e.indexOf(":")||(e=`\\${e}`),e}{let t=i;return t=e.normalize(t),e.isAbsolute(t)||(t=`/${t}`),t.endsWith("/")&&t.length>1&&(t=t.slice(0,-1)),t}}
1
+ import{posix as e,win32 as t}from"path";export function toValidFilePath(i,n){if(i?.length<1)return n?"\\":"/";if(n){let e=i;return e=t.normalize(e).replace(/\.$/g,""),e.endsWith("\\")&&e.length>1&&(e=e.replace(/\\+$/,"")),e.endsWith(":")&&(e=`${e}\\`),e.startsWith("\\")||-1!==e.indexOf(":")||(e=`\\${e}`),e}{let t=i;return t=e.normalize(t),"."===t?"/":(e.isAbsolute(t)||(t=`/${t}`),t.endsWith("/")&&t.length>1&&(t=t.slice(0,-1)),t)}}
@@ -0,0 +1 @@
1
+ export declare function hasBadWords(str: string, words?: string[]): boolean;
@@ -0,0 +1 @@
1
+ const o="ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ",t="ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ",n=" ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ",e={"ㅗㅏ":"ㅘ","ㅗㅐ":"ㅙ","ㅗㅣ":"ㅚ","ㅜㅓ":"ㅝ","ㅜㅔ":"ㅞ","ㅜㅣ":"ㅟ","ㅡㅣ":"ㅢ"},r={"ㄱㅅ":"ㄳ","ㄴㅈ":"ㄵ","ㄴㅎ":"ㄶ","ㄹㄱ":"ㄺ","ㄹㅁ":"ㄻ","ㄹㅂ":"ㄼ","ㄹㅅ":"ㄽ","ㄹㅌ":"ㄾ","ㄹㅍ":"ㄿ","ㄹㅎ":"ㅀ","ㅂㅅ":"ㅄ"},s={r:"ㅏ",i:"ㅣ"},f=o=>{const t={};for(const n of o)for(const o of n.slice(1))t[o]=n[0];return t},i=f(["a4àáâãäåāăąаα","b8вβ","cçćčс","dďđ","e3èéêëēĕėęěеёε","g9ğ","hн","i1lìíîïīįıłіι","jј","kкκ","mм","nñńň","o0òóôõöøōőоο","pрρ","s5śšşѕ","t7ţťтτ","uùúûüūůűų","xхχ","yýÿу","zźżž"]),c=f(["a@","c¢","e€£","i!|¡","s$§","t+","o°"]),u=/[\p{L}\p{N}]/u,d=o=>void 0!==o&&(t.includes(o)||void 0!==s[o]),l=(f,l)=>{const h=[];for(const e of f.toLowerCase()){let r=e;const s=r.codePointAt(0);s>=65281&&s<=65374?r=String.fromCharCode(s-65248).toLowerCase():s>=4352&&s<=4370?r=o[s-4352]:s>=4449&&s<=4469?r=t[s-4449]:s>=4520&&s<=4546&&(r=n[s-4519]),void 0!==i[r]?h.push(i[r]):u.test(r)?h.push(r):l&&void 0!==c[r]&&h.push(c[r])}for(let o=1,t=h.length;o<t;o+=1)"ㅇ"===h[o]&&h[o-1]>="a"&&h[o-1]<="z"&&(h[o]="o");return(f=>{const i=[],c=f.length;let u=0;for(;u<c;){const l=o.indexOf(f[u]);let h=u+1,p=h<c?t.indexOf(s[f[h]]??f[h]):-1;if(-1===l||-1===p){i.push(f[u]),u+=1;continue}h+=1;const g=h<c?e[t[p]+f[h]]:void 0;void 0!==g&&(p=t.indexOf(g),h+=1);let a=h<c&&!d(f[h+1])?Math.max(n.indexOf(f[h]),0):0;if(a>0){h+=1;const o=h<c?r[n[a]+f[h]]:void 0;void 0===o||d(f[h+1])||(a=n.indexOf(o),h+=1)}i.push(String.fromCharCode(44032+28*(21*l+p)+a)),u=h}return i.join("")})(h).replace(/ㅇ/g,"o")},h=(o,t,n,e)=>{for(let r=0,s=n.length;r<s;r+=1)if(o>=n[r]&&o<e[r])return o===n[r]||o+t<=e[r];return!1};export function hasBadWords(o,t=[]){if(!o||!t||0===t.length)return!1;const n=[];for(const o of t){if("string"!=typeof o)continue;const t=l(o,!0);t&&n.push(t)}if(0===n.length)return!1;const e=o.split(/\s+/).filter(o=>""!==o);for(const o of[!0,!1]){const t=[],r=[];let s="";for(const n of e){const e=l(n,o);e&&(t.push(s.length),s+=e,r.push(s.length))}for(const o of n){let n=s.indexOf(o);for(;-1!==n;){if(h(n,o.length,t,r))return!0;n=s.indexOf(o,n+1)}}}return!1}
@@ -1,5 +1,6 @@
1
1
  export { between } from './between.js';
2
2
  export { contains } from './contains.js';
3
+ export { hasBadWords } from './hasBadWords.js';
3
4
  export { is2dArray } from './is2dArray.js';
4
5
  export { isEmail } from './isEmail.js';
5
6
  export { isEmpty } from './isEmpty.js';
@@ -1 +1 @@
1
- export{between}from"./between.js";export{contains}from"./contains.js";export{is2dArray}from"./is2dArray.js";export{isEmail}from"./isEmail.js";export{isEmpty}from"./isEmpty.js";export{isEqual}from"./isEqual.js";export{isEqualStrict}from"./isEqualStrict.js";export{isObject}from"./isObject.js";export{isTrueMinimumNumberOfTimes}from"./isTrueMinimumNumberOfTimes.js";export{isUrl}from"./isUrl.js";export{len}from"./len.js";
1
+ export{between}from"./between.js";export{contains}from"./contains.js";export{hasBadWords}from"./hasBadWords.js";export{is2dArray}from"./is2dArray.js";export{isEmail}from"./isEmail.js";export{isEmpty}from"./isEmpty.js";export{isEqual}from"./isEqual.js";export{isEqualStrict}from"./isEqualStrict.js";export{isObject}from"./isObject.js";export{isTrueMinimumNumberOfTimes}from"./isTrueMinimumNumberOfTimes.js";export{isUrl}from"./isUrl.js";export{len}from"./len.js";
@@ -0,0 +1,2 @@
1
+ import type { ParsedAddress } from '../_types/global';
2
+ export declare function getParsedInfoFromAddress(url: string): ParsedAddress;
@@ -0,0 +1 @@
1
+ export function getParsedInfoFromAddress(t){const s={error:!1,protocol:void 0,host:void 0,port:void 0,user:void 0,pass:void 0};if("string"!=typeof t||""===t.trim())return s.error=!0,s;let e=t.trim();const o=/^([a-zA-Z][a-zA-Z0-9+.-]*):\/\//.exec(e);o&&(s.protocol=o[1].toUpperCase(),e=e.slice(o[0].length));const r=e.split(/[/?#]/)[0];if(""===r)return s;let i=r;const c=r.lastIndexOf("@");if(-1!==c){const t=r.slice(0,c);i=r.slice(c+1);const e=t.indexOf(":"),o=-1!==e?t.slice(0,e):t,n=-1!==e?t.slice(e+1):"";s.user=""===o?void 0:o,s.pass=""===n?void 0:n}const n=t=>{""!==t&&(!/^\d+$/.test(t)||Number(t)>65535?s.error=!0:s.port=Number(t))};if(i.startsWith("[")){const t=i.indexOf("]");if(-1===t)return s.error=!0,s;s.host=i.slice(0,t+1);const e=i.slice(t+1);""===e||(e.startsWith(":")?n(e.slice(1)):s.error=!0)}else{const t=(i.match(/:/g)||[]).length;if(t>=2)s.host=i;else if(1===t){const[t,e]=i.split(":");s.host=""===t?void 0:t,n(e)}else s.host=""===i?void 0:i}return s}
@@ -0,0 +1,2 @@
1
+ import type { SlugOptions } from '../_types/global';
2
+ export declare function getSlug(text: string, options?: SlugOptions): string;
@@ -0,0 +1 @@
1
+ const e=e=>/\s/.test(e)||"-"===e||"_"===e,t=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",o=e=>/\p{L}/u.test(e),r=e=>e>="0"&&e<="9",n=e=>encodeURIComponent(e).replace(/[!'()*.~]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`);export function getSlug(s,c={}){const{separator:p="-",includeNumbers:i=!0,includeSpecial:a=!1,uppercase:u=!1,includeNonLatin:l=!0,baseUrl:f=""}=c;if("string"!=typeof s||""===s.trim())return"";const d=s.trim(),g=u?d.toUpperCase():d.toLowerCase(),m=[];let C="";const U=()=>{C&&(m.push(C),C="")};for(const s of g)e(s)?U():t(s)?C+=s:o(s)?l&&(C+=s):r(s)?i&&(C+=s):a&&(C+=n(s));U();const $=m.join(p);if(!$)return"";const L=f.trim();return L?`${L.replace(/\/+$/,"")}/${$}`:$}
@@ -1,4 +1,6 @@
1
1
  export { generateLicense } from './generateLicense.js';
2
+ export { getParsedInfoFromAddress } from './getParsedInfoFromAddress.js';
3
+ export { getSlug } from './getSlug.js';
2
4
  export { isBotAgent } from './isBotAgent.js';
3
5
  export { isMatchPathname } from './isMatchPathname.js';
4
6
  export { isMobile } from './isMobile.js';
package/dist/web/index.js CHANGED
@@ -1 +1 @@
1
- export{generateLicense}from"./generateLicense.js";export{isBotAgent}from"./isBotAgent.js";export{isMatchPathname}from"./isMatchPathname.js";export{isMobile}from"./isMobile.js";export{removeLocalePrefix}from"./removeLocalePrefix.js";
1
+ export{generateLicense}from"./generateLicense.js";export{getParsedInfoFromAddress}from"./getParsedInfoFromAddress.js";export{getSlug}from"./getSlug.js";export{isBotAgent}from"./isBotAgent.js";export{isMatchPathname}from"./isMatchPathname.js";export{isMobile}from"./isMobile.js";export{removeLocalePrefix}from"./removeLocalePrefix.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.12.2",
3
+ "version": "1.13.1",
4
4
  "description": "qsu is a utility library that contains useful and frequently used functions. Start with your preferred language and the modern development environment.",
5
5
  "author": "CDGet <jooy2.contact@gmail.com>",
6
6
  "license": "MIT",
@@ -73,18 +73,18 @@
73
73
  ],
74
74
  "devDependencies": {
75
75
  "@eslint/js": "^9.39.2",
76
- "@types/node": "^25.9.2",
77
- "@typescript-eslint/parser": "^8.60.1",
76
+ "@types/node": "^26.1.1",
77
+ "@typescript-eslint/parser": "^8.65.0",
78
78
  "dayjs": "^1.11.21",
79
79
  "eslint": "^9.39.2",
80
80
  "eslint-config-prettier": "^10.1.8",
81
- "eslint-plugin-n": "^18.0.1",
82
- "globals": "^17.6.0",
81
+ "eslint-plugin-n": "^18.2.2",
82
+ "globals": "^17.7.0",
83
83
  "jiti": "^2.7.0",
84
- "prettier": "^3.8.3",
84
+ "prettier": "^3.9.6",
85
85
  "terser-glob": "^1.2.1",
86
- "tsx": "^4.22.4",
86
+ "tsx": "^4.23.1",
87
87
  "typescript": "6.0.3",
88
- "typescript-eslint": "^8.60.1"
88
+ "typescript-eslint": "^8.65.0"
89
89
  }
90
90
  }