qsu 1.10.1 → 1.10.3

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![logo](https://raw.githubusercontent.com/jooy2/qsu/main/.github/resources/logo.webp)
1
+ ![logo](https://raw.githubusercontent.com/jooy2/qsu/refs/heads/main/.github/resources/qsu-logo.webp)
2
2
 
3
3
  # qsu - Quick & Simple Utility
4
4
 
@@ -0,0 +1,2 @@
1
+ import type { PositiveNumber } from '../_types/global';
2
+ export declare function fileSizeFormat<N extends number>(bytes: PositiveNumber<N>, decimals?: number): string;
@@ -0,0 +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,4 +1,5 @@
1
1
  export { duration } from './duration.js';
2
+ export { fileSizeFormat } from './fileSizeFormat.js';
2
3
  export { numberFormat } from './numberFormat.js';
3
4
  export { safeJSONParse } from './safeJSONParse.js';
4
5
  export { safeParseInt } from './safeParseInt.js';
@@ -1 +1 @@
1
- export{duration}from"./duration.js";export{numberFormat}from"./numberFormat.js";export{safeJSONParse}from"./safeJSONParse.js";export{safeParseInt}from"./safeParseInt.js";
1
+ export{duration}from"./duration.js";export{fileSizeFormat}from"./fileSizeFormat.js";export{numberFormat}from"./numberFormat.js";export{safeJSONParse}from"./safeJSONParse.js";export{safeParseInt}from"./safeParseInt.js";
@@ -1 +1 @@
1
- import{stat as e}from"fs/promises";import{dirname as i,resolve as t}from"path";import{getFileExtension as r}from"./getFileExtension.js";import{getFileSize as s}from"./getFileSize.js";import{getFileName as o}from"./getFileName.js";export async function getFileInfo(m){const n=e=>Math.floor(new Date(e).getTime()/1e3);try{const a=await e(m);return{success:!0,isDirectory:a.isDirectory(),ext:r(m),size:a.size,sizeHumanized:s(a.size),name:o(m),dirname:i(m),path:t(m),created:n(a.ctime),modified:n(a.mtime)}}catch(e){if(e instanceof Error)throw new Error(e.message)}return{success:!1,isDirectory:!1,ext:null,size:0,sizeHumanized:"0 Bytes",name:"unknown",dirname:i(m),path:m,created:-1,modified:-1}}
1
+ import{stat as e}from"fs/promises";import{dirname as i,resolve as r}from"path";import{getFileExtension as t}from"./getFileExtension.js";import{fileSizeFormat as o}from"../../format/fileSizeFormat.js";import{getFileName as s}from"./getFileName.js";export async function getFileInfo(m){const n=e=>Math.floor(new Date(e).getTime()/1e3);try{const a=await e(m);return{success:!0,isDirectory:a.isDirectory(),ext:t(m),size:a.size,sizeHumanized:o(a.size),name:s(m),dirname:i(m),path:r(m),created:n(a.ctime),modified:n(a.mtime)}}catch(e){if(e instanceof Error)throw new Error(e.message)}return{success:!1,isDirectory:!1,ext:null,size:0,sizeHumanized:"0 Bytes",name:"unknown",dirname:i(m),path:m,created:-1,modified:-1}}
@@ -9,7 +9,6 @@ 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';
13
12
  export { getParentFilePath } from './getParentFilePath.js';
14
13
  export { headFile } from './headFile.js';
15
14
  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{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
+ 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";
@@ -0,0 +1 @@
1
+ export declare function getHostname(): Promise<string>;
@@ -0,0 +1 @@
1
+ import{hostname as n,platform as r}from"os";import{runCommand as t}from"./runCommand.js";export async function getHostname(){const e=r();let o;if("win32"===e)return process.env.COMPUTERNAME||n()||"Unknown";if("darwin"===e)o="scutil --get ComputerName";else{if("linux"!==e&&"freebsd"!==e)return n()||"Unknown";o="hostnamectl hostname"}try{const n=await t(o);if(n)return n}catch(n){if(n instanceof Error)throw new Error(n?.message)}return"Unknown"}
@@ -1,3 +1,4 @@
1
+ export { getHostname } from './getHostname.js';
1
2
  export { getMachineId } from './getMachineId.js';
2
3
  export { getSid } from './getSid.js';
3
4
  export { runCommand } from './runCommand.js';
@@ -1 +1 @@
1
- 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{getSid}from"./getSid.js";export{runCommand}from"./runCommand.js";
@@ -0,0 +1 @@
1
+ export declare function getStrBytes(str: string): number;
@@ -0,0 +1 @@
1
+ export function getStrBytes(t){if(!t)return 0;let o=0;for(const e of t){const t=e.codePointAt(0);t&&(o+=t<=127?1:t<=2047?2:t<=65535?3:4)}return o}
@@ -1,6 +1,7 @@
1
1
  export { capitalizeEachWords } from './capitalizeEachWords.js';
2
2
  export { capitalizeEverySentence } from './capitalizeEverySentence.js';
3
3
  export { capitalizeFirst } from './capitalizeFirst.js';
4
+ export { getStrBytes } from './getStrBytes.js';
4
5
  export { removeNewLine } from './removeNewLine.js';
5
6
  export { removeSpecialChar } from './removeSpecialChar.js';
6
7
  export { replaceBetween } from './replaceBetween.js';
@@ -1 +1 @@
1
- export{capitalizeEachWords}from"./capitalizeEachWords.js";export{capitalizeEverySentence}from"./capitalizeEverySentence.js";export{capitalizeFirst}from"./capitalizeFirst.js";export{removeNewLine}from"./removeNewLine.js";export{removeSpecialChar}from"./removeSpecialChar.js";export{replaceBetween}from"./replaceBetween.js";export{split}from"./split.js";export{strBlindRandom}from"./strBlindRandom.js";export{strCount}from"./strCount.js";export{strRandom}from"./strRandom.js";export{strShuffle}from"./strShuffle.js";export{strToAscii}from"./strToAscii.js";export{strUnique}from"./strUnique.js";export{trim}from"./trim.js";export{truncate}from"./truncate.js";export{truncateExpect}from"./truncateExpect.js";export{urlJoin}from"./urlJoin.js";
1
+ export{capitalizeEachWords}from"./capitalizeEachWords.js";export{capitalizeEverySentence}from"./capitalizeEverySentence.js";export{capitalizeFirst}from"./capitalizeFirst.js";export{getStrBytes}from"./getStrBytes.js";export{removeNewLine}from"./removeNewLine.js";export{removeSpecialChar}from"./removeSpecialChar.js";export{replaceBetween}from"./replaceBetween.js";export{split}from"./split.js";export{strBlindRandom}from"./strBlindRandom.js";export{strCount}from"./strCount.js";export{strRandom}from"./strRandom.js";export{strShuffle}from"./strShuffle.js";export{strToAscii}from"./strToAscii.js";export{strUnique}from"./strUnique.js";export{trim}from"./trim.js";export{truncate}from"./truncate.js";export{truncateExpect}from"./truncateExpect.js";export{urlJoin}from"./urlJoin.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
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,21 +73,20 @@
73
73
  "file"
74
74
  ],
75
75
  "devDependencies": {
76
- "@eslint/js": "^9.28.0",
77
- "@types/node": "^22.15.30",
78
- "@typescript-eslint/eslint-plugin": "^8.31.0",
79
- "@typescript-eslint/parser": "^8.31.0",
80
- "dayjs": "^1.11.13",
81
- "eslint": "^9.28.0",
82
- "eslint-config-prettier": "^10.1.5",
83
- "eslint-plugin-n": "^17.19.0",
84
- "glob": "^11.0.2",
85
- "globals": "^16.2.0",
86
- "jiti": "^2.4.2",
87
- "prettier": "^3.5.3",
76
+ "@eslint/js": "^9.39.1",
77
+ "@types/node": "^24.10.0",
78
+ "@typescript-eslint/parser": "^8.46.3",
79
+ "dayjs": "^1.11.19",
80
+ "eslint": "^9.39.1",
81
+ "eslint-config-prettier": "^10.1.8",
82
+ "eslint-plugin-n": "^17.23.1",
83
+ "glob": "^11.0.3",
84
+ "globals": "^16.5.0",
85
+ "jiti": "^2.6.1",
86
+ "prettier": "^3.6.2",
88
87
  "terser-glob": "^1.1.0",
89
- "tsx": "^4.19.4",
90
- "typescript": "^5.8.3",
91
- "typescript-eslint": "^8.31.0"
88
+ "tsx": "^4.20.6",
89
+ "typescript": "^5.9.3",
90
+ "typescript-eslint": "^8.46.3"
92
91
  }
93
92
  }
@@ -1,2 +0,0 @@
1
- import type { PositiveNumber } from '../../_types/global';
2
- export declare function getFileSize<N extends number>(bytes: PositiveNumber<N>, decimals?: number): string;
@@ -1 +0,0 @@
1
- export function getFileSize(t,o=2){const e=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t<1)return`0 ${e[0]}`;const B=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/1024**B).toFixed(o<0?0:o))} ${e[B]}`}