qsu 1.7.0 → 1.7.2

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,19 +1,19 @@
1
1
  ![logo](https://raw.githubusercontent.com/jooy2/qsu/main/.github/resources/logo.webp)
2
2
 
3
- # Qsu: Quick & Simple Utility for Node.js
3
+ # qsu: Quick & Simple Utility for Node.js
4
4
 
5
5
  [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jooy2/qsu/blob/main/LICENSE) ![Programming Language Usage](https://img.shields.io/github/languages/top/jooy2/qsu) ![Commit Count](https://img.shields.io/github/commit-activity/y/jooy2/qsu) [![npm downloads](https://img.shields.io/npm/dm/qsu.svg)](https://www.npmjs.com/package/qsu) [![npm latest package](https://img.shields.io/npm/v/qsu/latest.svg)](https://www.npmjs.com/package/qsu) ![npm maintenance](https://img.shields.io/npms-io/maintenance-score/qsu) ![npm quality](https://img.shields.io/npms-io/quality-score/qsu) ![minified size](https://img.shields.io/bundlephobia/min/qsu) [![Followers](https://img.shields.io/github/followers/jooy2?style=social)](https://github.com/jooy2) ![Stars](https://img.shields.io/github/stars/jooy2/qsu?style=social)
6
6
 
7
- **Qsu** is an underscore-based utility library optimized for the **[Node.js](https://nodejs.org)** development environment. It is supported in one module without the need to separately write frequently used methods for each project.
7
+ **qsu** is an underscore-based utility library optimized for the **[Node.js](https://nodejs.org)** development environment. It is supported in one module without the need to separately write frequently used methods for each project.
8
8
 
9
9
  - Lightweight and fast!
10
10
  - Easy to install and use.
11
11
  - 100% optimized for the latest Node.js and ESM environments.
12
12
  - Useful features for websites and web applications
13
13
 
14
- ## [Documentation (Getting Started & Method Reference)](https://qsu.cdget.com/getting-started/installation-javascript)
14
+ ## [Documentation (Getting Started & Method Reference)](https://qsu.cdget.com/installation/javascript)
15
15
 
16
- Installing and using the package and defining all the utility methods can be found on the documentation page below: https://qsu.cdget.com/getting-started/installation-javascript
16
+ Installing and using the package and defining all the utility methods can be found on the documentation page below: https://qsu.cdget.com/installation/javascript
17
17
 
18
18
  In addition, `qsu` is also available for the Dart language: https://github.com/jooy2/qsu-dart
19
19
 
@@ -1 +1 @@
1
- import{mkdir as r}from"fs/promises";import{isFileExists as i}from"./isFileExists.js";export async function createDirectory(t,e=!0){try{await i(t)||await r(t,{recursive:e})}catch(r){if(r instanceof Error)throw new Error(r.message)}}
1
+ import{mkdir as r}from"node:fs/promises";import{isFileExists as e}from"./isFileExists.js";export async function createDirectory(i,o=!0){try{await e(i)||await r(i,{recursive:o})}catch(r){if(r instanceof Error)throw new Error(r.message)}}
@@ -1 +1 @@
1
- import{open as t,utimes as a}from"fs/promises";export async function createFile(e){if(!e)return;const c=new Date;try{await a(e,c,c)}catch(a){const c=await t(e,"a");await c.close()}}
1
+ import{open as t,utimes as a}from"node:fs/promises";export async function createFile(e){if(!e)return;const o=new Date;try{await a(e,o,o)}catch(a){const o=await t(e,"a");await o.close()}}
@@ -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(r){return!1}}
1
+ import{open as r}from"node:fs/promises";import{createFile as e}from"./createFile.js";export async function createFileWithDummy(t,i){if(!i||i<0)throw new Error("Size is required");try{if(0===i)return await e(t),!0;const a=await r(t,"w");return await a.write(Buffer.alloc(1),0,1,i-1),await a.close(),!0}catch(r){return!1}}
@@ -1 +1 @@
1
- import{readdir as t}from"fs/promises";import{join as e}from"path";import{deleteFile as o}from"./deleteFile.js";export async function deleteAllFileFromDirectory(r){let i=[];try{i=await t(r)}catch{}const l=i.length;for(let t=0;t<l;t+=1)await o(e(r,i[t]))}
1
+ import{readdir as t}from"node:fs/promises";import{join as e}from"path";import{deleteFile as o}from"./deleteFile.js";export async function deleteAllFileFromDirectory(r){let i=[];try{i=await t(r)}catch{}const l=i.length;for(let t=0;t<l;t+=1)await o(e(r,i[t]))}
@@ -1 +1 @@
1
- import{rm as e}from"fs/promises";export async function deleteFile(r){if(r)try{await e(r,{recursive:!0,force:!0})}catch{}}
1
+ import{rm as e}from"node:fs/promises";export async function deleteFile(r){if(r)try{await e(r,{recursive:!0,force:!0})}catch{}}
@@ -1 +1 @@
1
- import{createHash as r}from"crypto";import{createReadStream as o}from"fs";export async function getFileHash(e,n="md5"){return new Promise(((t,i)=>{if(!e)return void i(new Error("Invalid path"));const a=r(n),d=o(e);d.on("error",(r=>{i(r)})),d.on("data",(r=>{a.update(r)})),d.on("end",(()=>{t(a.digest("hex"))}))}))}
1
+ import{createHash as r}from"crypto";import{createReadStream as o}from"node:fs";export async function getFileHash(e,n="md5"){return new Promise(((t,i)=>{if(!e)return void i(new Error("Invalid path"));const d=r(n),a=o(e);a.on("error",(r=>{i(r)})),a.on("data",(r=>{d.update(r)})),a.on("end",(()=>{t(d.digest("hex"))}))}))}
@@ -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"node:fs/promises";import{dirname as i,resolve as t}from"path";import{getFileExtension as r}from"./getFileExtension.js";import{getFileSize as o}from"./getFileSize.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:r(m),size:a.size,sizeHumanized:o(a.size),name:s(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 +1 @@
1
- import{readFile as r}from"fs/promises";export async function headFile(t,n=1){try{const e=(await r(t,"utf-8")).split("\n");let o="";for(let r=0,t=n;r<t;r+=1)o+=`${e[r]}${n<2||r===t-1?"":"\n"}`;return o.length<1?null:o}catch(r){if(r instanceof Error)throw new Error(r.message)}return null}
1
+ import{readFile as r}from"node: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 +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(r){return!1}}
1
+ import{access as r}from"node:fs/promises";import{constants as t}from"node:fs";export async function isFileExists(o){try{return await r(o,t.F_OK),!0}catch(r){return!1}}
@@ -1 +1 @@
1
- import{rename as o}from"fs/promises";export async function moveFile(i,e){i&&e&&await o(i,e)}
1
+ import{rename as o}from"node:fs/promises";export async function moveFile(e,i){e&&i&&await o(e,i)}
@@ -1 +1 @@
1
- import{readFile as t}from"fs/promises";export async function tailFile(n,e=1){try{const r=(await t(n,"utf-8")).split("\n");let l="";r[r.length-1].length<1&&r.pop();for(let t=r.length,n=r.length-e;t>n;t-=1)l=`${r[t-1]}${l.length<1||t-1===n?"":"\n"}${l}`;return l.length<1?null:l}catch(t){if(t instanceof Error)throw new Error(t.message)}return null}
1
+ import{readFile as t}from"node:fs/promises";import{EOL as n}from"os";export async function tailFile(r,e=1){try{const o=(await t(r,"utf-8")).split(n);let l="";o[o.length-1].length<1&&o.pop();for(let t=o.length,n=o.length-e;t>n;t-=1)l=`${o[t-1]}${l.length<1||t-1===n?"":"\n"}${l}`;return l.length<1?null:l}catch(t){if(t instanceof Error)throw new Error(t.message)}return null}
@@ -1 +1 @@
1
- export function numberFormat(r){return new Intl.NumberFormat("en-US",{roundingPriority:"morePrecision"}).format(r)}
1
+ export function numberFormat(t){const r="string"==typeof t?t.split("."):Math.abs(t).toString().split(".");return`${new Intl.NumberFormat("en-US",{roundingPriority:"morePrecision"}).format(parseInt(r[0],10))}${r.length>1?`.${r[1]}`:""}`}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.7.0",
4
- "description": "QSU is a lightweight and simple module with a variety of built-in utility functions that you can utilize in your Node.js projects.",
3
+ "version": "1.7.2",
4
+ "description": "qsu is a lightweight and simple module with a variety of built-in utility functions that you can utilize in your Node.js projects.",
5
5
  "author": "CDGet <jooy2.contact@gmail.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://qsu.cdget.com",
@@ -51,6 +51,7 @@
51
51
  "util",
52
52
  "utility",
53
53
  "tool",
54
+ "toolkit",
54
55
  "underscore",
55
56
  "website",
56
57
  "helper",