qsu 1.7.1 → 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/dist/file/createDirectory.js +1 -1
- package/dist/file/createFile.js +1 -1
- package/dist/file/createFileWithDummy.js +1 -1
- package/dist/file/deleteAllFileFromDirectory.js +1 -1
- package/dist/file/deleteFile.js +1 -1
- package/dist/file/getFileHash.js +1 -1
- package/dist/file/getFileInfo.js +1 -1
- package/dist/file/headFile.js +1 -1
- package/dist/file/isFileExists.js +1 -1
- package/dist/file/moveFile.js +1 -1
- package/dist/file/tailFile.js +1 -1
- package/dist/format/numberFormat.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdir as r}from"fs/promises";import{isFileExists as
|
|
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)}}
|
package/dist/file/createFile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{open as t,utimes as a}from"fs/promises";export async function createFile(e){if(!e)return;const
|
|
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
|
|
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]))}
|
package/dist/file/deleteFile.js
CHANGED
|
@@ -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{}}
|
package/dist/file/getFileHash.js
CHANGED
|
@@ -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
|
|
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"))}))}))}
|
package/dist/file/getFileInfo.js
CHANGED
|
@@ -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
|
|
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}}
|
package/dist/file/headFile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile as r}from"fs/promises";export async function headFile(
|
|
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(
|
|
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}}
|
package/dist/file/moveFile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rename as o}from"fs/promises";export async function moveFile(i
|
|
1
|
+
import{rename as o}from"node:fs/promises";export async function moveFile(e,i){e&&i&&await o(e,i)}
|
package/dist/file/tailFile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile as t}from"fs/promises";export async function tailFile(
|
|
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){
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qsu",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
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",
|