qsu 1.10.3 → 1.11.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2025 CDGet <jooy2.contact@gmail.com> (https://cdget.com).
3
+ Copyright (c) 2021-2026 CDGet <jooy2.contact@gmail.com> (https://cdget.com).
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,2 +1,2 @@
1
1
  import type { PositiveNumber } from '../_types/global';
2
- export declare function fileSizeFormat<N extends number>(bytes: PositiveNumber<N>, decimals?: number): string;
2
+ export declare function fileSizeFormat<N extends number>(bytes: PositiveNumber<N>, decimals?: number, ceil?: boolean): string;
@@ -1 +1 @@
1
- export function fileSizeFormat(t,o=2){const B=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t<1)return`0 ${B[0]}`;const e=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/1024**e).toFixed(o<0?0:o))} ${B[e]}`}
1
+ export function fileSizeFormat(t,o=2,e=!1){const B=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t<1)return`0 ${B[0]}`;const r=Math.floor(Math.log(t)/Math.log(1024)),a=t/1024**r;return`${e?Math.ceil(a):parseFloat(a.toFixed(o<0?0:o))} ${B[r]}`}
@@ -1 +1 @@
1
- export declare function getFileExtension(filePath: string, isWindows?: boolean): string | null;
1
+ export declare function getFileExtension(filePath: string): string | null;
@@ -1 +1 @@
1
- import{extname as t}from"path";export function getFileExtension(l,e){let n=l.split(e?"\\":"/").pop();return n?(n=t(n)||n,-1===n.indexOf(".")?null:n.split(".")?.pop()?.toLowerCase()||null):null}
1
+ import{extname as e}from"path";import{getFileName as t}from"./getFileName.js";export function getFileExtension(o){const r=e(t(o,!0)).replace(".","").toLowerCase();return r?.length>0?r:null}
@@ -1 +1 @@
1
- import{basename as e,extname as n,win32 as a}from"path";export function getFileName(t,i=!1){return t?-1===t.indexOf("/")&&-1!==t.indexOf("\\")?i?a.basename(t):a.basename(t,n(t)):i?e(t):e(t,n(t)):""}
1
+ import{posix as e,win32 as n}from"path";export function getFileName(a,t=!1){return-1===a.indexOf("/")&&-1!==a.indexOf("\\")?n.basename(a,t?void 0:n.extname(a))||"":e.basename(a,t?void 0:e.extname(a))||""}
@@ -0,0 +1 @@
1
+ export declare function getFileSize(filePath: string): Promise<number>;
@@ -0,0 +1 @@
1
+ import{stat as r}from"fs/promises";export async function getFileSize(e){try{return(await r(e)).size}catch(r){if(r instanceof Error)throw new Error(r.message)}return-1}
@@ -1 +1 @@
1
- import{toValidFilePath as t}from"./toValidFilePath.js";export function getParentFilePath(e,o){const i=e.split(o?"\\":"/");let n;return i.pop(),n=1===i.length?o?"C:\\":"/":i.join(o?"\\":"/"),t(n,o)}
1
+ import{toValidFilePath as t}from"./toValidFilePath.js";import{posix as r,win32 as e}from"path";export function getParentFilePath(i,a){return t(a?e.dirname(i):r.dirname(i),a)}
@@ -1 +1 @@
1
- import{readFile as r}from"fs/promises";import{EOL as t}from"os";export async function headFile(o,e=1){try{const n=(await r(o,"utf-8")).split(t);let s="";for(let r=0,t=e;r<t;r+=1)s+=`${n[r]}${e<2||r===t-1?"":"\n"}`;return s.length<1?null:s}catch(r){if(r instanceof Error)throw new Error(r.message)}return null}
1
+ import{createReadStream as n}from"fs";import{createInterface as o}from"node:readline";export async function headFile(e,r=1){return r<=0?null:new Promise(((l,t)=>{const i=n(e,{encoding:"utf-8"}),s=o({input:i,crlfDelay:1/0}),c=[];s.on("line",(n=>{c.push(n),c.length>=r&&(s.close(),i.destroy())})),s.on("close",(()=>{0===c.length?l(null):l(c.join("\n"))})),s.on("error",(n=>t(n))),i.on("error",(n=>t(n)))}))}
@@ -9,6 +9,7 @@ export { getFileHashFromStream } from './getFileHashFromStream.js';
9
9
  export { getFileInfo } from './getFileInfo.js';
10
10
  export { getFileName } from './getFileName.js';
11
11
  export { getFilePathLevel } from './getFilePathLevel.js';
12
+ export { getFileSize } from './getFileSize.js';
12
13
  export { getParentFilePath } from './getParentFilePath.js';
13
14
  export { headFile } from './headFile.js';
14
15
  export { isFileExists } from './isFileExists.js';
@@ -1 +1 @@
1
- export{createDirectory}from"./createDirectory.js";export{createFile}from"./createFile.js";export{createFileWithDummy}from"./createFileWithDummy.js";export{deleteAllFileFromDirectory}from"./deleteAllFileFromDirectory.js";export{deleteFile}from"./deleteFile.js";export{getFileExtension}from"./getFileExtension.js";export{getFileHashFromPath}from"./getFileHashFromPath.js";export{getFileHashFromStream}from"./getFileHashFromStream.js";export{getFileInfo}from"./getFileInfo.js";export{getFileName}from"./getFileName.js";export{getFilePathLevel}from"./getFilePathLevel.js";export{getParentFilePath}from"./getParentFilePath.js";export{headFile}from"./headFile.js";export{isFileExists}from"./isFileExists.js";export{isFileHidden}from"./isFileHidden.js";export{isValidFileName}from"./isValidFileName.js";export{joinFilePath}from"./joinFilePath.js";export{moveFile}from"./moveFile.js";export{normalizeFile}from"./normalizeFile.js";export{tailFile}from"./tailFile.js";export{toPosixFilePath}from"./toPosixFilePath.js";export{toValidFilePath}from"./toValidFilePath.js";
1
+ export{createDirectory}from"./createDirectory.js";export{createFile}from"./createFile.js";export{createFileWithDummy}from"./createFileWithDummy.js";export{deleteAllFileFromDirectory}from"./deleteAllFileFromDirectory.js";export{deleteFile}from"./deleteFile.js";export{getFileExtension}from"./getFileExtension.js";export{getFileHashFromPath}from"./getFileHashFromPath.js";export{getFileHashFromStream}from"./getFileHashFromStream.js";export{getFileInfo}from"./getFileInfo.js";export{getFileName}from"./getFileName.js";export{getFilePathLevel}from"./getFilePathLevel.js";export{getFileSize}from"./getFileSize.js";export{getParentFilePath}from"./getParentFilePath.js";export{headFile}from"./headFile.js";export{isFileExists}from"./isFileExists.js";export{isFileHidden}from"./isFileHidden.js";export{isValidFileName}from"./isValidFileName.js";export{joinFilePath}from"./joinFilePath.js";export{moveFile}from"./moveFile.js";export{normalizeFile}from"./normalizeFile.js";export{tailFile}from"./tailFile.js";export{toPosixFilePath}from"./toPosixFilePath.js";export{toValidFilePath}from"./toValidFilePath.js";
@@ -1 +1 @@
1
- import{posix as o,win32 as i}from"path";import{toValidFilePath as t}from"./toValidFilePath.js";export function joinFilePath(r,...n){return r?t(i.join(...n),!0):t(o.join(...n),!1)}
1
+ import{posix as o,win32 as i}from"path";import{toValidFilePath as t}from"./toValidFilePath.js";export function joinFilePath(r,...n){return t(r?i.join(...n):o.join(...n),r)}
@@ -1 +1 @@
1
- import{readFile as t}from"fs/promises";import{EOL as r}from"os";export async function tailFile(n,e=1){try{const l=(await t(n,"utf-8")).split(r);let o="";l[l.length-1].length<1&&l.pop();for(let t=l.length,r=l.length-e;t>r;t-=1)o=`${l[t-1]}${o.length<1||t-1===r?"":"\n"}${o}`;return o.length<1?null:o}catch(t){if(t instanceof Error)throw new Error(t.message)}return null}
1
+ import{createReadStream as n}from"fs";import{createInterface as o}from"node:readline";export async function tailFile(e,l=1){return l<=0?null:new Promise(((r,t)=>{const i=n(e,{encoding:"utf-8"}),u=o({input:i,crlfDelay:1/0}),f=[];u.on("line",(n=>{f.length===l&&f.shift(),f.push(n)})),u.on("close",(()=>{0!==f.length?(""===f[f.length-1]&&f.pop(),0!==f.length?r(f.join("\n")):r(null)):r(null)})),u.on("error",(n=>t(n))),i.on("error",(n=>t(n)))}))}
@@ -1 +1 @@
1
- export function toValidFilePath(e,t){if(t){let t=e;return t.length>2&&!/^[a-zA-Z]:/.test(t)&&(t=`\\${t}`),(t.match(/\\/g)||[]).length>1&&/\\$/.test(t)&&(t=t.replace(/\\$/,"")),/^[a-zA-Z]:$/.test(t)&&(t=`${t}\\`),t.replace(/\\{2,}/g,"\\")}let l=e;return/^\//.test(l)||(l=`/${l}`),l=l.replace(/\/{2,}/g,"/"),l.length>1&&(l=l.replace(/\/$/,"")),l}
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}}
@@ -0,0 +1 @@
1
+ export declare function getRamSize(): string;
@@ -0,0 +1 @@
1
+ import{totalmem as o}from"node:os";import{fileSizeFormat as r}from"../../format/fileSizeFormat.js";export function getRamSize(){return r(o(),0,!0)}
@@ -1,4 +1,5 @@
1
1
  export { getHostname } from './getHostname.js';
2
2
  export { getMachineId } from './getMachineId.js';
3
+ export { getRamSize } from './getRamSize.js';
3
4
  export { getSid } from './getSid.js';
4
5
  export { runCommand } from './runCommand.js';
@@ -1 +1 @@
1
- export{getHostname}from"./getHostname.js";export{getMachineId}from"./getMachineId.js";export{getSid}from"./getSid.js";export{runCommand}from"./runCommand.js";
1
+ export{getHostname}from"./getHostname.js";export{getMachineId}from"./getMachineId.js";export{getRamSize}from"./getRamSize.js";export{getSid}from"./getSid.js";export{runCommand}from"./runCommand.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.10.3",
3
+ "version": "1.11.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",
@@ -16,7 +16,7 @@
16
16
  "types": "dist/index.d.ts",
17
17
  "scripts": {
18
18
  "build": "tsc --project tsconfig.prod.json && npm run minify",
19
- "test": "npm run build && glob -c \"tsx --test\" \"./test/**/*.test.ts\"",
19
+ "test": "npm run build && glob-bin -c \"tsx --test\" \"./test/**/*.test.ts\"",
20
20
  "lint": "eslint . --ext .js,.ts .",
21
21
  "lint:fix": "eslint . --ext .js,.ts --fix .",
22
22
  "minify": "terser-glob 'dist/**/*.js' --config-file terser.config.json",
@@ -74,19 +74,19 @@
74
74
  ],
75
75
  "devDependencies": {
76
76
  "@eslint/js": "^9.39.1",
77
- "@types/node": "^24.10.0",
78
- "@typescript-eslint/parser": "^8.46.3",
77
+ "@types/node": "^24.10.1",
78
+ "@typescript-eslint/parser": "^8.48.0",
79
79
  "dayjs": "^1.11.19",
80
80
  "eslint": "^9.39.1",
81
81
  "eslint-config-prettier": "^10.1.8",
82
82
  "eslint-plugin-n": "^17.23.1",
83
- "glob": "^11.0.3",
83
+ "glob-bin": "^1.0.0",
84
84
  "globals": "^16.5.0",
85
85
  "jiti": "^2.6.1",
86
86
  "prettier": "^3.6.2",
87
87
  "terser-glob": "^1.1.0",
88
88
  "tsx": "^4.20.6",
89
89
  "typescript": "^5.9.3",
90
- "typescript-eslint": "^8.46.3"
90
+ "typescript-eslint": "^8.48.0"
91
91
  }
92
92
  }