qsu 1.10.0 → 1.10.1
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/dist/_types/global.js +0 -1
- package/dist/format/safeJSONParse.js +1 -1
- package/dist/format/safeParseInt.js +1 -1
- package/dist/node/file/createFile.js +1 -1
- package/dist/node/file/createFileWithDummy.js +1 -1
- package/dist/node/file/getFileHashFromPath.d.ts +1 -0
- package/dist/node/file/getFileHashFromPath.js +1 -0
- package/dist/node/file/getFileHashFromStream.d.ts +1 -0
- package/dist/node/file/getFileHashFromStream.js +1 -0
- package/dist/node/file/index.d.ts +2 -1
- package/dist/node/file/index.js +1 -1
- package/dist/node/file/isFileExists.js +1 -1
- package/dist/verify/isEmail.d.ts +1 -1
- package/dist/verify/isEmail.js +1 -1
- package/dist/verify/isUrl.js +1 -1
- package/package.json +17 -14
- package/dist/node/file/getFileHash.d.ts +0 -1
- package/dist/node/file/getFileHash.js +0 -1
package/dist/_types/global.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function safeJSONParse(r,t={}){if(!r)return t;if(Array.isArray(r)||"object"==typeof r)try{return JSON.parse(JSON.stringify(r))}catch
|
|
1
|
+
export function safeJSONParse(r,t={}){if(!r)return t;if(Array.isArray(r)||"object"==typeof r)try{return JSON.parse(JSON.stringify(r))}catch{return t}try{return JSON.parse(r)}catch{return t}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function safeParseInt(t,r=0,n=10){if(!t||t.toString().length<1)return r;try{return parseInt(t.toString().split(".")[0],n)}catch
|
|
1
|
+
export function safeParseInt(t,r=0,n=10){if(!t||t.toString().length<1)return r;try{return parseInt(t.toString().split(".")[0],n)}catch{return r}}
|
|
@@ -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
|
|
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{const a=await t(e,"a");await a.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
|
|
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{return!1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileHashFromPath(filePath: string, algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as r}from"crypto";import{createReadStream as o}from"fs";export async function getFileHashFromPath(t,e="md5"){return new Promise(((n,i)=>{if(!t)return void i(new Error("Invalid path"));const a=r(e),d=o(t);d.on("error",(r=>{i(r)})),d.on("data",(r=>{a.update(r)})),d.on("end",(()=>{n(a.digest("hex"))}))}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileHashFromStream(fileStream: NodeJS.ReadableStream, algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as r}from"crypto";import{pipeline as t}from"stream/promises";export async function getFileHashFromStream(e,o="md5"){if(!e)throw new Error("Invalid file stream detected");const i=r(o);return await t(e,i),i.digest("hex")}
|
|
@@ -4,7 +4,8 @@ export { createFileWithDummy } from './createFileWithDummy.js';
|
|
|
4
4
|
export { deleteAllFileFromDirectory } from './deleteAllFileFromDirectory.js';
|
|
5
5
|
export { deleteFile } from './deleteFile.js';
|
|
6
6
|
export { getFileExtension } from './getFileExtension.js';
|
|
7
|
-
export {
|
|
7
|
+
export { getFileHashFromPath } from './getFileHashFromPath.js';
|
|
8
|
+
export { getFileHashFromStream } from './getFileHashFromStream.js';
|
|
8
9
|
export { getFileInfo } from './getFileInfo.js';
|
|
9
10
|
export { getFileName } from './getFileName.js';
|
|
10
11
|
export { getFilePathLevel } from './getFilePathLevel.js';
|
package/dist/node/file/index.js
CHANGED
|
@@ -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{
|
|
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{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
|
|
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{return!1}}
|
package/dist/verify/isEmail.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isEmail(email: string): boolean;
|
|
1
|
+
export declare function isEmail(email: string, onlyLowerCase?: boolean): boolean;
|
package/dist/verify/isEmail.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function isEmail(
|
|
1
|
+
export function isEmail($,t=!1){const e=t?"a-z":"a-zA-Z";return new RegExp(`^[${e}0-9!#$%&'*+/=?^_\`{|}~-]+(?:\\.[${e}0-9!#$%&'*+/=?^_\`{|}~-]+)*@(?:[${e}0-9](?:[${e}0-9-]*[${e}0-9])?\\.)+[${e}0-9](?:[${e}0-9-]*[${e}0-9])?$`,"g").test($)}
|
package/dist/verify/isUrl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function isUrl(t,r=!1,n=!1){if(n&&-1===t.indexOf("."))return!1;try{new URL(`${r&&-1===t.indexOf("://")?"https://":""}${t}`).toString()}catch
|
|
1
|
+
export function isUrl(t,r=!1,n=!1){if(n&&-1===t.indexOf("."))return!1;try{new URL(`${r&&-1===t.indexOf("://")?"https://":""}${t}`).toString()}catch{return!1}return!0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qsu",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
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",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsc --project tsconfig.prod.json && npm run minify",
|
|
19
19
|
"test": "npm run build && glob -c \"tsx --test\" \"./test/**/*.test.ts\"",
|
|
20
|
-
"lint": "eslint .",
|
|
21
|
-
"lint:fix": "eslint --fix .",
|
|
20
|
+
"lint": "eslint . --ext .js,.ts .",
|
|
21
|
+
"lint:fix": "eslint . --ext .js,.ts --fix .",
|
|
22
22
|
"minify": "terser-glob 'dist/**/*.js' --config-file terser.config.json",
|
|
23
23
|
"prepare": "npm run build",
|
|
24
24
|
"format": "prettier .",
|
|
@@ -73,18 +73,21 @@
|
|
|
73
73
|
"file"
|
|
74
74
|
],
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@
|
|
77
|
-
"@
|
|
78
|
-
"@typescript-eslint/
|
|
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",
|
|
79
80
|
"dayjs": "^1.11.13",
|
|
80
|
-
"eslint": "
|
|
81
|
-
"eslint-config-
|
|
82
|
-
"eslint-
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
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",
|
|
86
88
|
"terser-glob": "^1.1.0",
|
|
87
|
-
"tsx": "^4.19.
|
|
88
|
-
"typescript": "^5.
|
|
89
|
+
"tsx": "^4.19.4",
|
|
90
|
+
"typescript": "^5.8.3",
|
|
91
|
+
"typescript-eslint": "^8.31.0"
|
|
89
92
|
}
|
|
90
93
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getFileHash(filePath: string, algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'): Promise<string>;
|
|
@@ -1 +0,0 @@
|
|
|
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"))}))}))}
|