qsu 1.10.2 → 1.10.4

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.
@@ -0,0 +1,2 @@
1
+ import type { PositiveNumber } from '../_types/global';
2
+ export declare function fileSizeFormat<N extends number>(bytes: PositiveNumber<N>, decimals?: number, ceil?: boolean): string;
@@ -0,0 +1 @@
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,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}}
@@ -1,2 +1 @@
1
- import type { PositiveNumber } from '../../_types/global';
2
- export declare function getFileSize<N extends number>(bytes: PositiveNumber<N>, decimals?: number): string;
1
+ export declare function getFileSize(filePath: string): Promise<number>;
@@ -1 +1 @@
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]}`}
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{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)))}))}
@@ -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)))}))}
@@ -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.2",
3
+ "version": "1.10.4",
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,20 +73,20 @@
73
73
  "file"
74
74
  ],
75
75
  "devDependencies": {
76
- "@eslint/js": "^9.37.0",
77
- "@types/node": "^24.7.2",
78
- "@typescript-eslint/parser": "^8.46.1",
79
- "dayjs": "^1.11.18",
80
- "eslint": "^9.37.0",
76
+ "@eslint/js": "^9.39.1",
77
+ "@types/node": "^24.10.1",
78
+ "@typescript-eslint/parser": "^8.48.0",
79
+ "dayjs": "^1.11.19",
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",
84
- "globals": "^16.4.0",
83
+ "glob": "^13.0.0",
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.1"
90
+ "typescript-eslint": "^8.48.0"
91
91
  }
92
92
  }