qsu 1.9.0 → 1.9.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,21 +1,26 @@
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
4
4
 
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)
5
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jooy2/qsu/blob/main/LICENSE) ![Commit Count](https://img.shields.io/github/commit-activity/y/jooy2/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 a library that collects frequently used utility functions. Streamline repetitive code with useful functions. Optimized for modern development environments, it supports various programming languages.
8
8
 
9
- - Lightweight and fast!
10
- - Easy to install and use.
11
- - 100% optimized for the latest Node.js and ESM environments.
12
- - Useful features for websites and web applications
9
+ The following are the advantages of the qsu:
13
10
 
14
- ## [Documentation (Getting Started & Method Reference)](https://qsu.cdget.com/installation/javascript)
11
+ - Fast, lightweight bundle size
12
+ - Install and use easily.
13
+ - It is suitable for use on websites or applications.
14
+ - Documents, prepared for secure data types.
15
+ - Reduce defects through fast maintenance and various test cases.
16
+ - Support for multiple programming languages for the same operation. (JavaScript, Dart)
15
17
 
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
18
+ ## Documentation
17
19
 
18
- In addition, `qsu` is also available for the Dart language: https://github.com/jooy2/qsu-dart
20
+ Installing and using the package and defining all the utility methods can be found on the documentation page below.
21
+
22
+ - [Installation](https://qsu.cdget.com/installation/javascript)
23
+ - [Reference](https://qsu.cdget.com/reference)
19
24
 
20
25
  ## Contributing
21
26
 
@@ -1 +1 @@
1
- import{createDecipheriv as t}from"node:crypto";export function decrypt(r,e,f="aes-256-cbc",o=!1){if(!r||r.length<1)return"";const n=o?"base64":"hex",c=r.split(":"),i=t(f,e,Buffer.from(c.shift(),n));let u=i.update(Buffer.from(c.join(":"),n));return u=Buffer.concat([u,i.final()]),u.toString()}
1
+ import{createDecipheriv as t}from"crypto";export function decrypt(r,e,f="aes-256-cbc",o=!1){if(!r||r.length<1)return"";const n=o?"base64":"hex",c=r.split(":"),i=t(f,e,Buffer.from(c.shift(),n));let u=i.update(Buffer.from(c.join(":"),n));return u=Buffer.concat([u,i.final()]),u.toString()}
@@ -1 +1 @@
1
- import{createCipheriv as t,randomBytes as n}from"node:crypto";export function encrypt(e,r,o="aes-256-cbc",c=16,f=!1){if(!e||e.length<1)return"";const i=n(c),a=t(o,r,i);let p=a.update(e);p=Buffer.concat([p,a.final()]);const u=f?"base64":"hex";return`${i.toString(u)}:${p.toString(u)}`}
1
+ import{createCipheriv as t,randomBytes as n}from"crypto";export function encrypt(r,e,o="aes-256-cbc",c=16,f=!1){if(!r||r.length<1)return"";const i=n(c),a=t(o,e,i);let p=a.update(r);p=Buffer.concat([p,a.final()]);const u=f?"base64":"hex";return`${i.toString(u)}:${p.toString(u)}`}
@@ -1 +1 @@
1
- import{createHash as t}from"node:crypto";export function md5Hash(e){return t("md5").update(e).digest("hex")}
1
+ import{createHash as t}from"crypto";export function md5Hash(r){return t("md5").update(r).digest("hex")}
@@ -1 +1 @@
1
- import{createHash as t}from"node:crypto";export function sha1Hash(e){return t("sha1").update(e).digest("hex")}
1
+ import{createHash as t}from"crypto";export function sha1Hash(r){return t("sha1").update(r).digest("hex")}
@@ -1 +1 @@
1
- import{createHash as t}from"node:crypto";export function sha256Hash(e){return t("sha256").update(e).digest("hex")}
1
+ import{createHash as t}from"crypto";export function sha256Hash(r){return t("sha256").update(r).digest("hex")}
@@ -1 +1 @@
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
+ 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 +1 @@
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
+ 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 +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
+ 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 +1 @@
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
+ 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 +1 @@
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
+ import{rm as e}from"fs/promises";export async function deleteFile(r){if(r)try{await e(r,{recursive:!0,force:!0})}catch{}}
@@ -1 +1 @@
1
- import{createHash as o}from"node:crypto";import{createReadStream as r}from"node:fs";export async function getFileHash(e,n="md5"){return new Promise(((t,d)=>{if(!e)return void d(new Error("Invalid path"));const i=o(n),a=r(e);a.on("error",(o=>{d(o)})),a.on("data",(o=>{i.update(o)})),a.on("end",(()=>{t(i.digest("hex"))}))}))}
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 +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
+ 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 +1 @@
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
+ 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 +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
+ 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 +1 @@
1
- import{rename as o}from"node:fs/promises";export async function moveFile(e,i){e&&i&&await o(e,i)}
1
+ import{rename as o}from"fs/promises";export async function moveFile(i,e){i&&e&&await o(i,e)}
@@ -1 +1 @@
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
+ 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}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.9.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.9.2",
4
+ "description": "qsu is a utility library that contains useful and frequently used functions. It contains useful functions for processing array, object, and string data. Start with your preferred programming language and the latest development environment.",
5
5
  "author": "CDGet <jooy2.contact@gmail.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://qsu.cdget.com",
@@ -58,6 +58,7 @@
58
58
  "tool",
59
59
  "toolkit",
60
60
  "underscore",
61
+ "web",
61
62
  "website",
62
63
  "helper",
63
64
  "array",
@@ -68,6 +69,7 @@
68
69
  "encrypt",
69
70
  "decrypt",
70
71
  "format",
72
+ "crypto",
71
73
  "file"
72
74
  ],
73
75
  "devDependencies": {