qsu 1.12.1 → 1.13.0
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/_types/global.d.ts +20 -0
- package/dist/array/arrPick.d.ts +1 -0
- package/dist/array/arrPick.js +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +1 -1
- package/dist/format/duration.js +1 -1
- package/dist/misc/index.d.ts +1 -0
- package/dist/misc/index.js +1 -1
- package/dist/misc/logBox.d.ts +1 -0
- package/dist/misc/logBox.js +1 -0
- package/dist/node/file/createFileWithDummy.js +1 -1
- package/dist/node/file/getCopyFileName.js +1 -1
- package/dist/node/file/getFilePathLevel.js +1 -1
- package/dist/node/file/isFileExists.js +1 -1
- package/dist/node/file/isValidFileName.js +1 -1
- package/dist/node/file/toValidFilePath.js +1 -1
- package/dist/web/getParsedInfoFromAddress.d.ts +2 -0
- package/dist/web/getParsedInfoFromAddress.js +1 -0
- package/dist/web/getSlug.d.ts +2 -0
- package/dist/web/getSlug.js +1 -0
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.js +1 -1
- package/package.json +9 -9
package/dist/_types/global.d.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrPick(array: any[]): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function arrPick(r){return!r||!Array.isArray(r)||r.length<1?null:r[Math.random()*r.length|0]}
|
package/dist/array/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { arrCount } from './arrCount.js';
|
|
2
2
|
export { arrGroupByMaxCount } from './arrGroupByMaxCount.js';
|
|
3
3
|
export { arrMove } from './arrMove.js';
|
|
4
|
+
export { arrPick } from './arrPick.js';
|
|
4
5
|
export { arrRepeat } from './arrRepeat.js';
|
|
5
6
|
export { arrShuffle } from './arrShuffle.js';
|
|
6
7
|
export { arrTo1dArray } from './arrTo1dArray.js';
|
package/dist/array/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{arrCount}from"./arrCount.js";export{arrGroupByMaxCount}from"./arrGroupByMaxCount.js";export{arrMove}from"./arrMove.js";export{arrRepeat}from"./arrRepeat.js";export{arrShuffle}from"./arrShuffle.js";export{arrTo1dArray}from"./arrTo1dArray.js";export{arrUnique}from"./arrUnique.js";export{arrWithDefault}from"./arrWithDefault.js";export{arrWithNumber}from"./arrWithNumber.js";export{average}from"./average.js";export{sortByObjectKey}from"./sortByObjectKey.js";export{sortNumeric}from"./sortNumeric.js";
|
|
1
|
+
export{arrCount}from"./arrCount.js";export{arrGroupByMaxCount}from"./arrGroupByMaxCount.js";export{arrMove}from"./arrMove.js";export{arrPick}from"./arrPick.js";export{arrRepeat}from"./arrRepeat.js";export{arrShuffle}from"./arrShuffle.js";export{arrTo1dArray}from"./arrTo1dArray.js";export{arrUnique}from"./arrUnique.js";export{arrWithDefault}from"./arrWithDefault.js";export{arrWithNumber}from"./arrWithNumber.js";export{average}from"./average.js";export{sortByObjectKey}from"./sortByObjectKey.js";export{sortNumeric}from"./sortNumeric.js";
|
package/dist/format/duration.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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)}
|
package/dist/misc/index.d.ts
CHANGED
package/dist/misc/index.js
CHANGED
|
@@ -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
|
|
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";
|
|
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(
|
|
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{
|
|
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
|
|
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 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 @@
|
|
|
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(/\/+$/,"")}/${$}`:$}
|
package/dist/web/index.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.13.0",
|
|
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": "^
|
|
77
|
-
"@typescript-eslint/parser": "^8.
|
|
78
|
-
"dayjs": "^1.11.
|
|
76
|
+
"@types/node": "^26.1.1",
|
|
77
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
78
|
+
"dayjs": "^1.11.21",
|
|
79
79
|
"eslint": "^9.39.2",
|
|
80
80
|
"eslint-config-prettier": "^10.1.8",
|
|
81
|
-
"eslint-plugin-n": "^18.
|
|
82
|
-
"globals": "^17.
|
|
81
|
+
"eslint-plugin-n": "^18.2.2",
|
|
82
|
+
"globals": "^17.7.0",
|
|
83
83
|
"jiti": "^2.7.0",
|
|
84
|
-
"prettier": "^3.
|
|
84
|
+
"prettier": "^3.9.6",
|
|
85
85
|
"terser-glob": "^1.2.1",
|
|
86
|
-
"tsx": "^4.
|
|
86
|
+
"tsx": "^4.23.1",
|
|
87
87
|
"typescript": "6.0.3",
|
|
88
|
-
"typescript-eslint": "^8.
|
|
88
|
+
"typescript-eslint": "^8.65.0"
|
|
89
89
|
}
|
|
90
90
|
}
|