qsu 1.13.2 → 1.15.0

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.
Files changed (73) hide show
  1. package/dist/array/arrMove.js +1 -1
  2. package/dist/array/arrRepeat.js +1 -1
  3. package/dist/array/arrShuffle.js +1 -1
  4. package/dist/array/arrTo1dArray.js +1 -1
  5. package/dist/array/arrUnique.js +1 -1
  6. package/dist/array/sortByObjectKey.js +1 -1
  7. package/dist/array/sortNumeric.js +1 -1
  8. package/dist/format/numberFormat.js +1 -1
  9. package/dist/format/safeParseInt.js +1 -1
  10. package/dist/math/numUnique.js +1 -1
  11. package/dist/misc/debounce.js +1 -1
  12. package/dist/misc/index.d.ts +0 -1
  13. package/dist/misc/index.js +1 -1
  14. package/dist/node/crypto/decrypt.js +1 -1
  15. package/dist/node/crypto/encrypt.d.ts +1 -0
  16. package/dist/node/crypto/encrypt.js +1 -1
  17. package/dist/node/crypto/md5Hash.js +1 -1
  18. package/dist/node/crypto/sha1Hash.js +1 -1
  19. package/dist/node/crypto/sha256Hash.js +1 -1
  20. package/dist/node/crypto/sha512Hash.js +1 -1
  21. package/dist/node/file/createDirectory.js +1 -1
  22. package/dist/node/file/createFile.js +1 -1
  23. package/dist/node/file/createFileWithDummy.js +1 -1
  24. package/dist/node/file/deleteAllFileFromDirectory.js +1 -1
  25. package/dist/node/file/deleteFile.js +1 -1
  26. package/dist/node/file/getCopyFileName.d.ts +1 -1
  27. package/dist/node/file/getCopyFileName.js +1 -1
  28. package/dist/node/file/getFileExtension.js +1 -1
  29. package/dist/node/file/getFileHashFromPath.js +1 -1
  30. package/dist/node/file/getFileHashFromStream.js +1 -1
  31. package/dist/node/file/getFileInfo.js +1 -1
  32. package/dist/node/file/getFileName.js +1 -1
  33. package/dist/node/file/getFilePathLevel.js +1 -1
  34. package/dist/node/file/getFileSize.js +1 -1
  35. package/dist/node/file/getParentFilePath.js +1 -1
  36. package/dist/node/file/headFile.js +1 -1
  37. package/dist/node/file/isFileExists.js +1 -1
  38. package/dist/node/file/isFileHidden.js +1 -1
  39. package/dist/node/file/isValidFileName.js +1 -1
  40. package/dist/node/file/joinFilePath.js +1 -1
  41. package/dist/node/file/moveFile.js +1 -1
  42. package/dist/node/file/tailFile.js +1 -1
  43. package/dist/node/file/toValidFilePath.js +1 -1
  44. package/dist/node/index.d.ts +1 -0
  45. package/dist/node/index.js +1 -1
  46. package/dist/node/misc/index.d.ts +1 -0
  47. package/dist/node/misc/index.js +1 -0
  48. package/dist/node/net/fetchData.js +1 -1
  49. package/dist/node/os/getCpu.js +1 -1
  50. package/dist/node/os/getHostname.js +1 -1
  51. package/dist/node/os/getMachineId.js +1 -1
  52. package/dist/node/os/getSid.js +1 -1
  53. package/dist/node/os/runCommand.js +1 -1
  54. package/dist/object/objDeleteKeyByValue.js +1 -1
  55. package/dist/object/objMergeNewKey.js +1 -1
  56. package/dist/object/objTo1d.js +1 -1
  57. package/dist/object/objToArray.js +1 -1
  58. package/dist/object/objUpdate.js +1 -1
  59. package/dist/string/capitalizeEverySentence.js +1 -1
  60. package/dist/string/replaceBetween.js +1 -1
  61. package/dist/string/strBlindRandom.js +1 -1
  62. package/dist/string/strRandom.js +1 -1
  63. package/dist/string/trim.js +1 -1
  64. package/dist/verify/hasBadWords.js +1 -1
  65. package/dist/verify/is2dArray.js +1 -1
  66. package/dist/verify/isEqual.js +1 -1
  67. package/dist/verify/isEqualStrict.js +1 -1
  68. package/dist/web/generateLicense.js +1 -1
  69. package/package.json +3 -3
  70. package/dist/verify/isUnique.d.ts +0 -1
  71. package/dist/verify/isUnique.js +0 -0
  72. /package/dist/{misc → node/misc}/logBox.d.ts +0 -0
  73. /package/dist/{misc → node/misc}/logBox.js +0 -0
@@ -1 +1 @@
1
- export function arrMove(r,e,n){const o=r.length;if(o<=e||o<=n)throw new Error("Invalid move params");return r.splice(n,0,r.splice(e,1)[0]),r}
1
+ export function arrMove(r,e,n){const o=r.length;if(o<=e||o<=n)throw new Error("Invalid move params");const t=[...r];return t.splice(n,0,t.splice(e,1)[0]),t}
@@ -1 +1 @@
1
- import{isObject as r}from"../verify/isObject.js";export function arrRepeat(t,e){if(!t||e<1||"object"!=typeof t)return[];const o=r(t),f=[];for(let r=0,p=e;r<p;r+=1)o?f.push(t):f.push(...t);return f}
1
+ import{isObject as e}from"../verify/isObject.js";export function arrRepeat(t,r){if(!t||r<1||"object"!=typeof t)return[];const o=e(t),f=[];for(let e=0,i=r;e<i;e+=1)if(o)f.push(t);else for(let e=0;e<t.length;e+=1)f.push(t[e]);return f}
@@ -1 +1 @@
1
- export function arrShuffle(t){if(1===t.length)return t[0];const r=t;for(let n=t.length-1;n>0;n-=1){const o=Math.floor(Math.random()*(n+1));[r[n],r[o]]=[t[o],t[n]]}return r}
1
+ export function arrShuffle(t){const o=[...t];for(let t=o.length-1;t>0;t-=1){const r=Math.floor(Math.random()*(t+1));[o[t],o[r]]=[o[r],o[t]]}return o}
@@ -1 +1 @@
1
- import{is2dArray as r}from"../verify/is2dArray.js";export function arrTo1dArray(t){const o=t=>{const e=[],n=t.length;for(let s=0;s<n;s+=1)"object"!=typeof t[s]?e.push(t[s]):r(t[s])?e.push(...o(t[s])):e.push(...t[s]);return e};return o(t)}
1
+ import{is2dArray as r}from"../verify/is2dArray.js";export function arrTo1dArray(t){const e=t=>{const o=[],n=t.length;for(let s=0;s<n;s+=1)if(Array.isArray(t[s])){const n=r(t[s])?e(t[s]):t[s];for(let r=0;r<n.length;r+=1)o.push(n[r])}else o.push(t[s]);return o};return e(t)}
@@ -1 +1 @@
1
- import{is2dArray as r}from"../verify/is2dArray.js";export function arrUnique(e){return r(e)?Array.from(new Set(e.map(r=>JSON.stringify(r))),r=>JSON.parse(r)):[...new Set(e)]}
1
+ import{is2dArray as r}from"../verify/is2dArray.js";export function arrUnique(t){if(r(t)){const r=new Set,e=[];for(let n=0;n<t.length;n+=1){const i=JSON.stringify(t[n]);void 0===i?e.push(t[n]):r.has(i)||(r.add(i),e.push(t[n]))}return e}return[...new Set(t)]}
@@ -1 +1 @@
1
- export function sortByObjectKey(r,e,t=!1,o=!1){if(o){const o=new Intl.Collator([],{numeric:!0}),n=r.sort((r,t)=>o.compare(r[e],t[e]));return t?n.reverse():n}return r.sort((r,o)=>t?r[e]>o[e]?-1:r[e]<o[e]?1:0:r[e]<o[e]?-1:r[e]>o[e]?1:0)}
1
+ const o=new Intl.Collator([],{numeric:!0});export function sortByObjectKey(r,t,e=!1,n=!1){return n?[...r].sort((r,n)=>e?o.compare(n[t],r[t]):o.compare(r[t],n[t])):[...r].sort((o,r)=>e?o[t]>r[t]?-1:o[t]<r[t]?1:0:o[t]<r[t]?-1:o[t]>r[t]?1:0)}
@@ -1 +1 @@
1
- export function sortNumeric(r,e=!1){const o=new Intl.Collator([],{numeric:!0}),t=r.sort((r,e)=>o.compare(r,e));return e?t.reverse():t}
1
+ const r=new Intl.Collator([],{numeric:!0});export function sortNumeric(o,t=!1){return[...o].sort((o,e)=>t?r.compare(e,o):r.compare(o,e))}
@@ -1 +1 @@
1
- export function numberFormat(t){if(null==t)return"";const r="string"==typeof t?t:t.toString(),n=r.startsWith("-"),e=(n?r.slice(1):r).split("."),i=`${new Intl.NumberFormat("en-US",{roundingPriority:"morePrecision"}).format(parseInt(e[0],10))}${e.length>1?`.${e[1]}`:""}`;return n?`-${i}`:i}
1
+ const t=/^\d+$/,n=new Intl.NumberFormat("en-US",{roundingPriority:"morePrecision"});export function numberFormat(r){if(null==r)return"";const e="string"==typeof r?r:r.toString(),o=e.startsWith("-"),i=(o?e.slice(1):e).split("."),s=t.test(i[0])?function(t){let n="";for(let r=t.length;r>0;r-=3){const e=t.slice(Math.max(0,r-3),r);n=""===n?e:`${e},${n}`}return n}(i[0]):n.format(parseInt(i[0],10)),l=`${s}${i.length>1?`.${i[1]}`:""}`;return o?`-${l}`:l}
@@ -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{return r}}
1
+ export function safeParseInt(t,r=0,n=10){if(null==t)return r;try{const e=t.toString();if(e.length<1)return r;const s=parseInt(e.split(".")[0],n);return Number.isNaN(s)?r:s}catch{return r}}
@@ -1 +1 @@
1
- export function numUnique(){const e=[...Array(89999).keys()].map(e=>e+1e4);return parseInt((new Date).valueOf()+""+e[Math.floor(Math.random()*e.length)],10)}
1
+ let e=0;export function numUnique(){const n=1e3*(new Date).valueOf();return e=n>e?n:e+1,e}
@@ -1 +1 @@
1
- export function debounce(e,t){let o;return(...u)=>{clearTimeout(o),o=setTimeout(()=>{e.apply(u)},t)}}
1
+ export function debounce(e,t){let u;return(...n)=>{u&&clearTimeout(u),u=setTimeout(()=>{e(...n)},t),u?.unref?.()}}
@@ -1,4 +1,3 @@
1
1
  export { debounce } from './debounce.js';
2
2
  export { funcTimes } from './funcTimes.js';
3
- export { logBox } from './logBox.js';
4
3
  export { sleep } from './sleep.js';
@@ -1 +1 @@
1
- export{debounce}from"./debounce.js";export{funcTimes}from"./funcTimes.js";export{logBox}from"./logBox.js";export{sleep}from"./sleep.js";
1
+ export{debounce}from"./debounce.js";export{funcTimes}from"./funcTimes.js";export{sleep}from"./sleep.js";
@@ -1 +1 @@
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
+ import{createDecipheriv as t}from"node:crypto";import{AEAD_ALGORITHM as r}from"./encrypt.js";export function decrypt(e,n,f="aes-256-cbc",o=!1){if(!e||e.length<1)return"";const i=o?"base64":"hex",u=e.split(":"),c=r.test(f);if(u.length<(c?3:2))throw new Error(c?"`str` must be in the `iv:authTag:encrypted` format returned by `encrypt`.":"`str` must be in the `iv:encrypted` format returned by `encrypt`.");const s=Buffer.from(u.shift(),i),p=c?Buffer.from(u.shift(),i):null,m=t(f,n,s);p&&m.setAuthTag(p);let a=m.update(Buffer.from(u.join(":"),i));return a=Buffer.concat([a,m.final()]),a.toString()}
@@ -1 +1,2 @@
1
+ export declare const AEAD_ALGORITHM: RegExp;
1
2
  export declare function encrypt(str: string, secret: string, algorithm?: string, ivSize?: number, toBase64?: boolean): string;
@@ -1 +1 @@
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
+ import{createCipheriv as t,randomBytes as n}from"node:crypto";export const AEAD_ALGORITHM=/gcm|ccm|ocb|poly1305/i;export function encrypt(o,r,e="aes-256-cbc",c=16,i=!1){if(!o||o.length<1)return"";const g=n(c),f=t(e,r,g);let p=f.update(o);p=Buffer.concat([p,f.final()]);const s=i?"base64":"hex";if(AEAD_ALGORITHM.test(e)){const t=f.getAuthTag();return`${g.toString(s)}:${t.toString(s)}:${p.toString(s)}`}return`${g.toString(s)}:${p.toString(s)}`}
@@ -1 +1 @@
1
- import{createHash as t}from"crypto";export function md5Hash(r,e){return t("md5").update(r).digest(e??"hex")}
1
+ import{createHash as t}from"node:crypto";export function md5Hash(e,o){return t("md5").update(e).digest(o??"hex")}
@@ -1 +1 @@
1
- import{createHash as t}from"crypto";export function sha1Hash(r,e){return t("sha1").update(r).digest(e??"hex")}
1
+ import{createHash as t}from"node:crypto";export function sha1Hash(e,o){return t("sha1").update(e).digest(o??"hex")}
@@ -1 +1 @@
1
- import{createHash as t}from"crypto";export function sha256Hash(r,e){return t("sha256").update(r).digest(e??"hex")}
1
+ import{createHash as t}from"node:crypto";export function sha256Hash(e,o){return t("sha256").update(e).digest(o??"hex")}
@@ -1 +1 @@
1
- import{createHash as t}from"crypto";export function sha512Hash(r,e){return t("sha512").update(r).digest(e??"hex")}
1
+ import{createHash as t}from"node:crypto";export function sha512Hash(e,o){return t("sha512").update(e).digest(o??"hex")}
@@ -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,stat as i}from"node:fs/promises";export async function createDirectory(t,e=!0){if(e)await r(t,{recursive:!0});else try{await r(t)}catch(r){if("EEXIST"!==r?.code)throw r;if(!(await i(t)).isDirectory())throw 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{const a=await t(e,"a");await a.close()}}
1
+ import{mkdir as t,open as a,utimes as e}from"node:fs/promises";import{dirname as r}from"node:path";export async function createFile(i){if(!i?.trim())return;const o=new Date;try{await e(i,o,o)}catch{await t(r(i),{recursive:!0});const e=await a(i,"a");await e.close()}}
@@ -1 +1 @@
1
- import{open as r}from"fs/promises";import{createFile as e}from"./createFile.js";export async function createFileWithDummy(t,i){if(null==i)throw new Error("Size is required");if(i<0)throw new Error("Size must be 0 or greater");try{if(0===i)return await e(t),!0;const o=await r(t,"w");return await o.write(Buffer.alloc(1),0,1,i-1),await o.close(),!0}catch{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(null==i)throw new Error("Size is required");if(i<0)throw new Error("Size must be 0 or greater");try{if(0===i)return await e(t),!0;const o=await r(t,"w");return await o.write(Buffer.alloc(1),0,1,i-1),await o.close(),!0}catch{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 e}from"node:fs/promises";import{join as t}from"node:path";import{deleteFile as o}from"./deleteFile.js";export async function deleteAllFileFromDirectory(r){let i=[];try{i=await e(r)}catch{}const l=i.length;for(let e=0;e<l;e+=32)await Promise.all(i.slice(e,e+32).map(e=>o(t(r,e))))}
@@ -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?.trim())try{await e(r,{recursive:!0,force:!0})}catch{}}
@@ -1 +1 @@
1
- export declare function getCopyFileName(fileName: string, fileNameList: string[]): string;
1
+ export declare function getCopyFileName(fileName: string, fileNameList: string[] | Set<string>): string;
@@ -1 +1 @@
1
- import{getFileName as e}from"./getFileName.js";export function getCopyFileName(t,n){const o=e(t),r=e(t,!0).slice(o.length),i=new Set(n);if(!i.has(t))return t;for(let e=1;;e++){const t=`${o} (${e})${r}`;if(!i.has(t))return t}}
1
+ import{getFileName as e}from"./getFileName.js";export function getCopyFileName(t,n){const o=e(t),i=e(t,!0).slice(o.length),r=n instanceof Set?n:new Set(n);if(!r.has(t))return t;for(let e=1;;e++){const t=`${o} (${e})${i}`;if(!r.has(t))return t}}
@@ -1 +1 @@
1
- import{extname as e}from"path";import{getFileName as t}from"./getFileName.js";export function getFileExtension(o){const r=e(t(o,!0)).replace(".","").toLowerCase();return r?.length>0?r:null}
1
+ import{extname as e}from"node:path";import{getFileName as t}from"./getFileName.js";export function getFileExtension(o){const n=e(t(o,!0)).replace(".","").toLowerCase();return n?.length>0?n:null}
@@ -1 +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"))})})}
1
+ import{createHash as r}from"node:crypto";import{createReadStream as o}from"node:fs";import{pipeline as t}from"node:stream/promises";export async function getFileHashFromPath(e,i="md5"){if(!e)throw new Error("Invalid path");const a=r(i);return await t(o(e,{highWaterMark:1048576}),a),a.digest("hex")}
@@ -1 +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")}
1
+ import{createHash as e}from"node:crypto";import{pipeline as r}from"node:stream/promises";export async function getFileHashFromStream(t,o="md5"){if(!t)throw new Error("Invalid file stream detected");const i=e(o);return await r(t,i),i.digest("hex")}
@@ -1 +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
+ import{stat as e}from"node:fs/promises";import{dirname as i,resolve as t}from"node:path";import{getFileExtension as o}from"./getFileExtension.js";import{fileSizeFormat as r}from"../../format/fileSizeFormat.js";import{getFileName as m}from"./getFileName.js";export async function getFileInfo(s){const a=e=>Math.floor(new Date(e).getTime()/1e3),n=await e(s);return{success:!0,isDirectory:n.isDirectory(),ext:o(s),size:n.size,sizeHumanized:r(n.size),name:m(s),dirname:i(s),path:t(s),created:a(n.ctime),modified:a(n.mtime)}}
@@ -1 +1 @@
1
- import{posix as e,win32 as n}from"path";export function getFileName(t,i=!1){const a=!i&&!t.endsWith("/")&&!t.endsWith("\\");return-1===t.indexOf("/")&&-1!==t.indexOf("\\")?n.basename(t,a?n.extname(t):void 0)||"":e.basename(t,a?e.extname(t):void 0)||""}
1
+ import{posix as e,win32 as n}from"node:path";export function getFileName(t,i=!1){const a=!i&&!t.endsWith("/")&&!t.endsWith("\\");return-1===t.indexOf("/")&&-1!==t.indexOf("\\")?n.basename(t,a?n.extname(t):void 0)||"":e.basename(t,a?e.extname(t):void 0)||""}
@@ -1 +1 @@
1
- import{posix as t}from"path";import{toPosixFilePath as e}from"./toPosixFilePath.js";export function getFilePathLevel(o){return o?"/"===o?1:e(o.replace(/[\\/]+$/,"")).split(t.sep).length:-1}
1
+ import{posix as e}from"node:path";import{toPosixFilePath as t}from"./toPosixFilePath.js";export function getFilePathLevel(o){return o?"/"===o?1:t(o.replace(/[\\/]+$/,"")).split(e.sep).length:-1}
@@ -1 +1 @@
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
+ import{stat as e}from"node:fs/promises";export async function getFileSize(i){return(await e(i)).size}
@@ -1 +1 @@
1
- import{toValidFilePath as t}from"./toValidFilePath.js";import{posix as r,win32 as e}from"path";export function getParentFilePath(i,a){return t(a?e.dirname(i):r.dirname(i),a)}
1
+ import{toValidFilePath as t}from"./toValidFilePath.js";import{posix as r,win32 as e}from"node:path";export function getParentFilePath(i,o){return t(o?e.dirname(i):r.dirname(i),o)}
@@ -1 +1 @@
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
+ import{createReadStream as n}from"node: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{stat as r}from"fs/promises";export async function isFileExists(t){try{return await r(t),!0}catch{return!1}}
1
+ import{stat as r}from"node:fs/promises";export async function isFileExists(t){try{return await r(t),!0}catch{return!1}}
@@ -1 +1 @@
1
- import{exec as e}from"child_process";export function isFileHidden(i,r=!1){return new Promise(t=>{r?e(`attrib "${i}"`,(e,r,o)=>{t(!(e||o||!r)&&r.replace(i,"").includes("H"))}):t(/(^|\/)\.[^/.]/.test(i.split("/")?.pop()||"/"))})}
1
+ import{execFile as i}from"node:child_process";const t=/^(.*?)\s+(?:[A-Za-z]:\\|\\\\)/;export function isFileHidden(e,n=!1){return new Promise(r=>{n?i("attrib",[e],(i,e,n)=>{if(i||n||!e)return void r(!1);const o=e.split(/\r?\n/).find(i=>i.trim().length>0)||"",s=t.exec(o);r(!!s&&s[1].includes("H"))}):r(/(^|\/)\.[^/.]/.test(e.split("/")?.pop()||"/"))})}
@@ -1 +1 @@
1
- import{getFileName as t}from"./getFileName.js";const e=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;export function isValidFileName(i,n){let s;const l=t(i,!0);if(n)s=/(^\s+$)|(^\.+$)|([:/]+)/;else if(s=/(^\s+$)|(^\.+$)|([<>:"/\\|?*]+)/,e.test(l.split(".")[0]))return!1;return!s.test(l)&&l.length<=255}
1
+ import{getFileName as t}from"./getFileName.js";const e=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i,n=/[\u0000-\u001F\u007F]/;export function isValidFileName(r,i){let s;const u=t(r,!0);if(u.length<1||n.test(u))return!1;if(i)s=/(^\s+$)|(^\.+$)|([:/]+)/;else{if(s=/(^\s+$)|(^\.+$)|([<>:"/\\|?*]+)/,e.test(u.split(".")[0]))return!1;if(/[. ]$/.test(u))return!1}return!s.test(u)&&Buffer.byteLength(u,"utf8")<=255}
@@ -1 +1 @@
1
- import{posix as o,win32 as i}from"path";import{toValidFilePath as t}from"./toValidFilePath.js";export function joinFilePath(r,...n){return t(r?i.join(...n):o.join(...n),r)}
1
+ import{posix as o,win32 as i}from"node:path";import{toValidFilePath as t}from"./toValidFilePath.js";export function joinFilePath(n,...r){return t(n?i.join(...r):o.join(...r),n)}
@@ -1 +1 @@
1
- import{rename as o}from"fs/promises";export async function moveFile(i,e){i&&e&&await o(i,e)}
1
+ import{copyFile as i,mkdir as t,readdir as a,rename as r,rm as o,stat as e}from"node:fs/promises";import{join as c}from"node:path";async function n(r,o){if(!(await e(r)).isDirectory())return void await i(r,o);await t(o,{recursive:!0});const f=await a(r);for(let i=0,t=f.length;i<t;i+=1)await n(c(r,f[i]),c(o,f[i]))}export async function moveFile(i,t){if(i?.trim()&&t?.trim())try{await r(i,t)}catch(a){if("EXDEV"!==a?.code)throw a;await n(i,t),await o(i,{recursive:!0,force:!0})}}
@@ -1 +1 @@
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))})}
1
+ import{open as t}from"node:fs/promises";const n=/\r\n|\n|\r/;function o(t){const o=t.split(n);return o.length>1&&""===o[o.length-1]&&o.pop(),o}export async function tailFile(n,e=1){if(e<=0)return null;const l=await t(n,"r");try{const{size:t}=await l.stat();if(0===t)return null;const n=[];let r=t,i=[];for(;r>0;){const t=Math.min(65536,r);r-=t;const s=Buffer.alloc(t);if(await l.read(s,0,t,r),n.unshift(s),i=o(Buffer.concat(n).toString("utf-8")),i.length>e)break}const s=i.slice(-e);return s.length>0&&""===s[s.length-1]&&s.pop(),0===s.length?null:s.join("\n")}finally{await l.close()}}
@@ -1 +1 @@
1
- import{posix as e,win32 as t}from"path";export function toValidFilePath(i,n){if(i?.length<1)return n?"\\":"/";if(n){let e=i;return e=t.normalize(e).replace(/\.$/g,""),e.endsWith("\\")&&e.length>1&&(e=e.replace(/\\+$/,"")),e.endsWith(":")&&(e=`${e}\\`),e.startsWith("\\")||-1!==e.indexOf(":")||(e=`\\${e}`),e}{let t=i;return t=e.normalize(t),"."===t?"/":(e.isAbsolute(t)||(t=`/${t}`),t.endsWith("/")&&t.length>1&&(t=t.slice(0,-1)),t)}}
1
+ import{posix as e,win32 as t}from"node:path";export function toValidFilePath(i,n){if(i?.length<1)return n?"\\":"/";if(n){let e=i;return e=t.normalize(e).replace(/\.$/g,""),e.startsWith("\\")||-1!==e.indexOf(":")||(e=t.normalize(`\\${e}`)),e.endsWith("\\")&&e.length>1&&(e=e.replace(/\\+$/,"")),e.endsWith(":")&&(e=`${e}\\`),e}{let t=i;return t=e.normalize(t),"."===t?"/":(e.isAbsolute(t)||(t=e.normalize(`/${t}`)),t.endsWith("/")&&t.length>1&&(t=t.slice(0,-1)),t)}}
@@ -1,4 +1,5 @@
1
1
  export * from './crypto/index.js';
2
2
  export * from './file/index.js';
3
+ export * from './misc/index.js';
3
4
  export * from './net/index.js';
4
5
  export * from './os/index.js';
@@ -1 +1 @@
1
- export*from"./crypto/index.js";export*from"./file/index.js";export*from"./net/index.js";export*from"./os/index.js";
1
+ export*from"./crypto/index.js";export*from"./file/index.js";export*from"./misc/index.js";export*from"./net/index.js";export*from"./os/index.js";
@@ -0,0 +1 @@
1
+ export { logBox } from './logBox.js';
@@ -0,0 +1 @@
1
+ export{logBox}from"./logBox.js";
@@ -1 +1 @@
1
- import{objToQueryString as t}from"../../object/objToQueryString.js";import{urlJoin as e}from"../../string/urlJoin.js";import{Readable as r}from"node:stream";function a(t){let e;if(t?.headers?.["Content-Type"])e=t?.headers?.["Content-Type"];else switch(t?.bodyType){case"form-data":e="multipart/form-data";break;case"x-www-form-urlencoded":e="application/x-www-form-urlencoded";break;case"json":e="application/json;charset=UTF-8";break;case"text":e="plain/text;charset=UTF-8";break;default:e=null}const r={};return t?.auth?.bearer&&t?.auth?.bearer.length>0&&(r.Authorization=`Bearer ${t?.auth?.bearer}`),t?.auth?.apiKey&&t?.auth?.apiKey.length>0&&(r["x-API-key"]=t?.auth?.apiKey),{...r,...e?{"Content-Type":e}:{},"Accept-Encoding":"gzip, deflate, br",Charset:"utf-8",...t?.headers}}export async function fetchData(o,i){const n=i||{},s=n.queryParameters?`?${t(n.queryParameters)}`:null;let h,l,u=null;if(o.length<1)throw new Error("`url` is required");if(n.body)switch(n.bodyType){case"x-www-form-urlencoded":u=t(n.body);break;case"form-data":u=n.body;break;default:u=JSON.stringify(n.body)}if(n.method&&(n.get||n.post||n.put||n.delete||n.patch))throw new Error("`method` and `get|post|put|delete|patch` cannot be used together");if(h=n.get?"GET":n.post?"POST":n.put?"PUT":n.delete?"DELETE":n.patch?"PATCH":n.method||"GET",!n.host&&!o.startsWith("/"))throw new Error("`url` must begin with `/`.");if(n.host&&n.host.length>0){if(o.startsWith("http")||o.includes("://"))throw new Error("If `host` is specified, `url` must begin with `/`.");l=e(n.host,o)}else l=o;try{const t=await fetch(e(l,s),{...n.auth?{credentials:"include"}:{},...n.timeout?{signal:AbortSignal.timeout(n.timeout)}:{},method:h,body:u,headers:a(n)});if(!t.ok||!t.body)return null;const o=t.headers.get("content-type")||"",i=function(t,e){if(/attachment|filename=/i.test(e))return!0;const r=t.split(";")?.[0]?.trim()?.toLowerCase()||"";return!["text/html","text/css","text/javascript","application/json","application/ld+json","application/xml","text/xml","text/plain"].some(t=>r===t)&&!r.startsWith("text/")&&(r.startsWith("application/")||r.startsWith("image/")||r.startsWith("video/")||r.startsWith("audio/")||r.startsWith("font/"))}(o,t.headers.get("content-disposition")||"");return n.toStream?r.fromWeb(t.body):i?Buffer.from(await t.arrayBuffer()):o.length<1?await t.text():o.includes("application/json")?await t.json():await t.text()}catch(t){return n.onError&&n.onError(t),null}}
1
+ import{objToQueryString as t}from"../../object/objToQueryString.js";import{urlJoin as e}from"../../string/urlJoin.js";import{Readable as r}from"node:stream";function a(t){let e;if(t?.headers?.["Content-Type"])e=t?.headers?.["Content-Type"];else switch(t?.bodyType){case"form-data":default:e=null;break;case"x-www-form-urlencoded":e="application/x-www-form-urlencoded";break;case"json":e="application/json;charset=UTF-8";break;case"text":e="plain/text;charset=UTF-8"}const r={};return t?.auth?.bearer&&t?.auth?.bearer.length>0&&(r.Authorization=`Bearer ${t?.auth?.bearer}`),t?.auth?.apiKey&&t?.auth?.apiKey.length>0&&(r["x-API-key"]=t?.auth?.apiKey),{...r,...e?{"Content-Type":e}:{},"Accept-Encoding":"gzip, deflate, br",Charset:"utf-8",...t?.headers}}export async function fetchData(o,i){const n=i||{},s=n.queryParameters?`?${t(n.queryParameters)}`:null;let h,l,c=null;if(o.length<1)throw new Error("`url` is required");if(n.body)switch(n.bodyType){case"x-www-form-urlencoded":c=t(n.body);break;case"form-data":c=n.body;break;default:c=JSON.stringify(n.body)}if(n.method&&(n.get||n.post||n.put||n.delete||n.patch))throw new Error("`method` and `get|post|put|delete|patch` cannot be used together");if(h=n.get?"GET":n.post?"POST":n.put?"PUT":n.delete?"DELETE":n.patch?"PATCH":n.method||"GET",!n.host&&!o.startsWith("/"))throw new Error("`url` must begin with `/`.");if(n.host&&n.host.length>0){if(o.startsWith("http")||o.includes("://"))throw new Error("If `host` is specified, `url` must begin with `/`.");l=e(n.host,o)}else l=o;try{const t=await fetch(e(l,s),{...n.auth?{credentials:"include"}:{},...n.timeout?{signal:AbortSignal.timeout(n.timeout)}:{},method:h,body:c,headers:a(n)});if(!t.ok||!t.body)return null;const o=t.headers.get("content-type")||"",i=function(t,e){if(/attachment|filename=/i.test(e))return!0;const r=t.split(";")?.[0]?.trim()?.toLowerCase()||"";return!["text/html","text/css","text/javascript","application/json","application/ld+json","application/xml","text/xml","text/plain"].some(t=>r===t)&&!r.startsWith("text/")&&(r.startsWith("application/")||r.startsWith("image/")||r.startsWith("video/")||r.startsWith("audio/")||r.startsWith("font/"))}(o,t.headers.get("content-disposition")||"");return n.toStream?r.fromWeb(t.body):i?Buffer.from(await t.arrayBuffer()):o.length<1?await t.text():o.includes("application/json")?await t.json():await t.text()}catch(t){return n.onError&&n.onError(t),null}}
@@ -1 +1 @@
1
- import{cpus as o}from"os";export function getCpu(){return`${o()?.[0]?.model||"Unknown"}`}
1
+ import{cpus as o}from"node:os";export function getCpu(){return`${o()?.[0]?.model||"Unknown"}`}
@@ -1 +1 @@
1
- import{hostname as n,platform as r}from"os";import{runCommand as t}from"./runCommand.js";export async function getHostname(){const e=r();let o;if("win32"===e)return process.env.COMPUTERNAME||n()||"Unknown";if("darwin"===e)o="scutil --get ComputerName";else{if("linux"!==e&&"freebsd"!==e)return n()||"Unknown";o="hostnamectl hostname"}try{const n=await t(o);if(n)return n}catch(n){if(n instanceof Error)throw new Error(n?.message)}return"Unknown"}
1
+ import{hostname as n,platform as r}from"node:os";import{runCommand as e}from"./runCommand.js";export async function getHostname(){const t=r();let o;if("win32"===t)return process.env.COMPUTERNAME||n()||"Unknown";if("darwin"===t)o="scutil --get ComputerName";else{if("linux"!==t&&"freebsd"!==t)return n()||"Unknown";o="hostnamectl hostname"}try{const n=await e(o);if(n)return n}catch(n){if(n instanceof Error)throw new Error(n?.message)}return"Unknown"}
@@ -1 +1 @@
1
- import{platform as r}from"os";import{runCommand as e}from"./runCommand.js";export async function getMachineId(){const i=r();let t;t="win32"===i?"for /f \"tokens=3 delims= \" %i in ('REG QUERY HKLM\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid ^| findstr MachineGuid') do @echo %i":"darwin"===i?"ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/' | cut -d '\"' -f4":"freebsd"===i?"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid":"(cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname) | head -n 1 || :";try{const r=await e(t);if(r)return r}catch(r){if(r instanceof Error)throw new Error(r?.message)}throw new Error("Failed to get machine id")}
1
+ import{platform as e}from"node:os";import{runCommand as r}from"./runCommand.js";export async function getMachineId(){const i=e();let o;o="win32"===i?"for /f \"tokens=3 delims= \" %i in ('REG QUERY HKLM\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid ^| findstr MachineGuid') do @echo %i":"darwin"===i?"ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/' | cut -d '\"' -f4":"freebsd"===i?"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid":"(cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname) | head -n 1 || :";try{const e=await r(o);if(e)return e}catch(e){if(e instanceof Error)throw new Error(e?.message)}throw new Error("Failed to get machine id")}
@@ -1 +1 @@
1
- import{homedir as r,platform as t,userInfo as o}from"os";import{runCommand as e}from"./runCommand.js";export async function getSid(){const n=t();if("win32"===n){try{const t=await e('REG QUERY "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList" /s');if(!t)throw new Error("Failed to get machine id");const o={};t.split("HKEY_LOCAL_MACHINE\\").forEach(r=>{const t=r.split("\n").map(r=>r.trim()).filter(r=>r);if(t.length>0){const r=t[0].split("\\").pop()||"Unknown",e=t.find(r=>r.startsWith("ProfileImagePath"));e&&(o[r]=e.split(" ").pop()||"Unknown")}});for(let t=0;t<Object.keys(o).length;t+=1){const e=Object.keys(o)[t];if(o[e]===r())return e}}catch(r){if(r instanceof Error)throw new Error(r?.message)}throw new Error("Failed to get machine id")}if("darwin"===n){try{const r=await e(`dsmemberutil getsid -U ${o().username}`);if(r)return r.replace(/\r?\n/g,"")}catch(r){if(r instanceof Error)throw new Error(r?.message)}throw new Error("Failed to get machine id")}throw new Error("Not supported on this operating system.")}
1
+ import{homedir as r,platform as t,userInfo as o}from"node:os";import{runCommand as e}from"./runCommand.js";export async function getSid(){const n=t();if("win32"===n){try{const t=await e('REG QUERY "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList" /s');if(!t)throw new Error("Failed to get machine id");const o={};t.split("HKEY_LOCAL_MACHINE\\").forEach(r=>{const t=r.split("\n").map(r=>r.trim()).filter(r=>r);if(t.length>0){const r=t[0].split("\\").pop()||"Unknown",e=t.find(r=>r.startsWith("ProfileImagePath"));e&&(o[r]=e.split(" ").pop()||"Unknown")}});for(let t=0;t<Object.keys(o).length;t+=1){const e=Object.keys(o)[t];if(o[e]===r())return e}}catch(r){if(r instanceof Error)throw new Error(r?.message)}throw new Error("Failed to get machine id")}if("darwin"===n){try{const r=await e(`dsmemberutil getsid -U ${o().username}`);if(r)return r.replace(/\r?\n/g,"")}catch(r){if(r instanceof Error)throw new Error(r?.message)}throw new Error("Failed to get machine id")}throw new Error("Not supported on this operating system.")}
@@ -1 +1 @@
1
- import{exec as e}from"child_process";import{EOL as n}from"os";export function runCommand(o){return new Promise((r,i)=>{const s=e(o,{encoding:"utf8",windowsHide:!0},(e,o)=>{e?i(e):(s?.stdin?.end(),r(o.replace(new RegExp(`${n}$`),"")))})})}
1
+ import{exec as e}from"node:child_process";import{EOL as n}from"node:os";export function runCommand(o){return new Promise((r,d)=>{const i=e(o,{encoding:"utf8",windowsHide:!0},(e,o)=>{e?d(e):(i?.stdin?.end(),r(o.replace(new RegExp(`${n}$`),"")))})})}
@@ -1 +1 @@
1
- import{isObject as e}from"../verify/isObject.js";export function objDeleteKeyByValue(t,o,l=!1){if(!t||"object"!=typeof t)return null;const n=Object.assign(t,{});for(let t=Object.keys(n).length;t>=0;t-=1){const r=Object.keys(n)[t];l&&n[r]&&e(n[r])?objDeleteKeyByValue(n[r],o,l):n[r]===o&&delete n[r]}return n}
1
+ import{isObject as e}from"../verify/isObject.js";export function objDeleteKeyByValue(t,o,l=!1){if(!t||"object"!=typeof t)return null;const r={...t},n=Object.keys(r);for(let t=n.length-1;t>=0;t-=1){const y=n[t];l&&r[y]&&e(r[y])?r[y]=objDeleteKeyByValue(r[y],o,l):r[y]===o&&delete r[y]}return r}
@@ -1 +1 @@
1
- import{isObject as e}from"../verify/isObject.js";export function objMergeNewKey(r,t,o){if(!r||"object"!=typeof r||!t||"object"!=typeof t)return null;const n={...r};return Object.keys(t).forEach(r=>{const i=t[r];if(Object.hasOwn(n,r))if(Array.isArray(n[r])&&Array.isArray(i)){if("append"===o?.arrayAction)n[r].push(...i);else if("replace"===o?.arrayAction)n[r]=i;else if(n[r].length===i.length)for(let t=0;t<n[r].length;t+=1){const s=i[t];e(s)&&(n[r][t]=objMergeNewKey(n[r][t],s,o))}}else e(n[r])&&e(i)?n[r]=objMergeNewKey(n[r],i,o):n[r]=i;else n[r]=i}),n}
1
+ import{isObject as e}from"../verify/isObject.js";export function objMergeNewKey(r,t,o){if(!r||"object"!=typeof r||!t||"object"!=typeof t)return null;const n={...r};return Object.keys(t).forEach(r=>{const c=t[r];if(Object.hasOwn(n,r))if(Array.isArray(n[r])&&Array.isArray(c)){if("append"===o?.arrayAction)n[r]=n[r].concat(c);else if("replace"===o?.arrayAction)n[r]=c;else if(n[r].length===c.length){const t=[...n[r]];for(let r=0;r<t.length;r+=1){const n=c[r];e(n)&&(t[r]=objMergeNewKey(t[r],n,o))}n[r]=t}}else e(n[r])&&e(c)?n[r]=objMergeNewKey(n[r],c,o):n[r]=c;else n[r]=c}),n}
@@ -1 +1 @@
1
- import{isObject as e}from"../verify/isObject.js";export function objTo1d(t,r="."){if(!r||r.length<1)throw new Error("`separator` must have value at least 1 character.");const o=(t,n="")=>{let s={};const c=Object.keys(t).length,a=n.length<1;for(let l=0;l<c;l+=1){const c=Object.keys(t)[l],h=t[c],i=`${n}${a?"":r}${c}`;e(h)?(s=Object.assign(s,o(h,i)),delete s[c]):s[i]=h}return s};return o(t)}
1
+ import{isObject as t}from"../verify/isObject.js";export function objTo1d(e,r="."){if(!r||r.length<1)throw new Error("`separator` must have value at least 1 character.");const o=(e,n="")=>{let s={};const a=Object.keys(e),c=n.length<1;for(let l=0,h=a.length;l<h;l+=1){const h=a[l],i=e[h],f=`${n}${c?"":r}${h}`;t(i)?(s=Object.assign(s,o(i,f)),delete s[h]):s[f]=i}return s};return o(e)}
@@ -1 +1 @@
1
- import{isObject as t}from"../verify/isObject.js";export function objToArray(e,r=!1){const o=e=>{const s=[],n=Object.keys(e).length;for(let c=0;c<n;c+=1){const n=Object.keys(e)[c];r&&t(e[n])?s.push([n,o(e[n])]):s.push([n,e[n]])}return s};return o(e)}
1
+ import{isObject as t}from"../verify/isObject.js";export function objToArray(r,o=!1){const e=r=>{const n=[],s=Object.keys(r);for(let c=0,u=s.length;c<u;c+=1){const u=s[c];o&&t(r[u])?n.push([u,e(r[u])]):n.push([u,r[u]])}return n};return e(r)}
@@ -1 +1 @@
1
- import{isObject as t}from"../verify/isObject.js";export function objUpdate(e,n,o,c=!1,s=!1){if(!e||"object"!=typeof e)return null;const r=Object.assign(e,{});let j=!1;const b=e=>{for(let s=0;s<Object.keys(e).length;s+=1){const r=Object.keys(e)[s];c&&e[r]&&t(e[r])&&b(e[r]),Object.hasOwn(e,n)&&(e[n]=o,j=!0)}};return b(r),!j&&s&&(r[n]=o),r}
1
+ import{isObject as t}from"../verify/isObject.js";export function objUpdate(e,n,o,r=!1,c=!1){if(!e||"object"!=typeof e)return null;let s=!1;const f=e=>{const c={...e},j=Object.keys(c);for(let e=0,n=j.length;e<n;e+=1){const n=j[e];r&&c[n]&&t(c[n])&&(c[n]=f(c[n]))}return Object.hasOwn(c,n)&&(c[n]=o,s=!0),c},j=f(e);return!s&&c&&(j[n]=o),j}
@@ -1 +1 @@
1
- export function capitalizeEverySentence(e,t){if(!e)return"";const n=t||".",r=e.split(n);let i,l="";for(let e=0,t=r.length;e<t;e+=1){i=[...r[e]];for(let t=0,n=i.length;t<n;t+=1)if(/[a-zA-Z]/.test(r[e][t])){i[t]=r[e][t].toUpperCase();break}l+=`${i.join("")}${e<t-1?n:""}`}return l}
1
+ const e=/[a-zA-Z]/;export function capitalizeEverySentence(t,n){if(!t)return"";const r=n||".",o=t.split(r);let i,l="";for(let t=0,n=o.length;t<n;t+=1){i=[...o[t]];for(let t=0,n=i.length;t<n;t+=1)if(e.test(i[t])){i[t]=i[t].toUpperCase();break}l+=`${i.join("")}${t<n-1?r:""}`}return l}
@@ -1 +1 @@
1
- export function replaceBetween(e,t,n,r=""){if(!e)return"";const $=/[.*+?^${}()|[\]\\]/g,c=$.test(t)?`\\${t}`:t,p=$.test(n)?`\\${n}`:n;return e.replace(new RegExp(`${c}.*?${p}`,"g"),r)}
1
+ const e=/[.*+?^${}()|[\]\\]/g,n=n=>n.replace(e,"\\$&");export function replaceBetween(e,r,t,c=""){if(!e)return"";const p=n(r),o=n(t);return e.replace(new RegExp(`${p}.*?${o}`,"g"),c)}
@@ -1 +1 @@
1
- import{numPick as t}from"../math/numPick.js";export function strBlindRandom(n,r,s="*"){if(!n)return"";let i=n,o=0,u=0,e=0;const m=i.length;for(;o<r&&e<m;)u=t(0,m),/[a-zA-Z가-힣]/.test(i.substring(u,u+1))&&(i=`${i.substring(0,u+1)}${s}${i.substring(u+2)}`,o+=1),e+=1;return i}
1
+ import{numPick as t}from"../math/numPick.js";const n=/[a-zA-Z가-힣]/;export function strBlindRandom(r,s,i="*"){if(!r)return"";let o=r,u=0,e=0,m=0;const c=o.length;for(;u<s&&m<c;)e=t(0,c-1),n.test(o.substring(e,e+1))&&(o=`${o.substring(0,e)}${i}${o.substring(e+1)}`,u+=1),m+=1;return o}
@@ -1 +1 @@
1
- export function strRandom(t,o){const r=`abcdefghijklmnopqrstuvwxyz0123456789${o}`,a=r.length;let n,e="";for(let o=0;o<t;o+=1)n=r.charAt(Math.floor(Math.random()*a)),n=Math.random()<.5?n.toUpperCase():n,e+=n;return e}
1
+ export function strRandom(t,o){const r=`abcdefghijklmnopqrstuvwxyz0123456789${o??""}`,a=r.length;let n,e="";for(let o=0;o<t;o+=1)n=r.charAt(Math.floor(Math.random()*a)),n=Math.random()<.5?n.toUpperCase():n,e+=n;return e}
@@ -1 +1 @@
1
- export function trim(r){return"string"==typeof r||r?r.trim().replace(/\s{2,}/g," "):null}
1
+ export function trim(r){return"string"!=typeof r?null:r.trim().replace(/\s{2,}/g," ")}
@@ -1 +1 @@
1
- const o="ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ",t="ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ",n=" ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ",e={"ㅗㅏ":"ㅘ","ㅗㅐ":"ㅙ","ㅗㅣ":"ㅚ","ㅜㅓ":"ㅝ","ㅜㅔ":"ㅞ","ㅜㅣ":"ㅟ","ㅡㅣ":"ㅢ"},r={"ㄱㅅ":"ㄳ","ㄴㅈ":"ㄵ","ㄴㅎ":"ㄶ","ㄹㄱ":"ㄺ","ㄹㅁ":"ㄻ","ㄹㅂ":"ㄼ","ㄹㅅ":"ㄽ","ㄹㅌ":"ㄾ","ㄹㅍ":"ㄿ","ㄹㅎ":"ㅀ","ㅂㅅ":"ㅄ"},f={r:"ㅏ",i:"ㅣ"},s=o=>{const t={};for(const n of o)for(const o of n.slice(1))t[o]=n[0];return t},i=[9398,119808,119860,119912,120224,120276,120328,120380,120432],c=o=>{for(const t of i)if(o>=t&&o<=t+51)return String.fromCharCode(97+(o-t)%26)},l=s(["a4àáâãäåāăąаα","b8вβ","cçćčс","dďđ","e3èéêëēĕėęěеёε","g69ğ","hн","i1lìíîïīįıłіι","jј","kкκ","mм","nñńň","o0òóôõöøōőоο","pрρ","s5śšşѕ","t7ţťтτ","uùúûüūůűų","xхχ","yýÿу","z2źżž"]),d=s(["a@","c¢(","e€£","i!|¡/","s$§","t+","o°"]),h=/[\p{L}\p{N}]/u,u=o=>void 0!==o&&(t.includes(o)||void 0!==f[o]),g=(s,i)=>{const g=[];for(const e of s.toLowerCase()){let r=e;const f=r.codePointAt(0);f>=65281&&f<=65374?r=String.fromCharCode(f-65248).toLowerCase():f>=4352&&f<=4370?r=o[f-4352]:f>=4449&&f<=4469?r=t[f-4449]:f>=4520&&f<=4546?r=n[f-4519]:f>=9398&&(r=c(f)??r),void 0!==l[r]?g.push(l[r]):h.test(r)?g.push(r):i&&void 0!==d[r]&&g.push(d[r])}for(let o=1,t=g.length;o<t;o+=1)"ㅇ"===g[o]&&g[o-1]>="a"&&g[o-1]<="z"&&(g[o]="o");return(s=>{const i=[],c=s.length;let l=0;for(;l<c;){const d=o.indexOf(s[l]);let h=l+1,g=h<c?t.indexOf(f[s[h]]??s[h]):-1;if(-1===d||-1===g){i.push(s[l]),l+=1;continue}h+=1;const p=h<c?e[t[g]+s[h]]:void 0;void 0!==p&&(g=t.indexOf(p),h+=1);let a=h<c&&!u(s[h+1])?Math.max(n.indexOf(s[h]),0):0;if(a>0){h+=1;const o=h<c?r[n[a]+s[h]]:void 0;void 0===o||u(s[h+1])||(a=n.indexOf(o),h+=1)}i.push(String.fromCharCode(44032+28*(21*d+g)+a)),l=h}return i.join("")})(g).replace(/ㅇ/g,"o")},p=(o,t,n,e)=>{for(let r=0,f=n.length;r<f;r+=1)if(o>=n[r]&&o<e[r])return o===n[r]||o+t<=e[r];return!1},a=o=>{const t=[];for(const n of o){if("string"!=typeof n)continue;const o=g(n,!0);o&&t.push(o)}return t};export function hasBadWords(o,t=[],n=[]){if(!o||!t||0===t.length)return!1;const e=a(t);if(0===e.length)return!1;const r=n?a(n):[],f=o.split(/\s+/).filter(o=>""!==o);for(const o of[!0,!1]){const t=[],n=[];let s="";for(const e of f){const r=g(e,o);r&&(t.push(s.length),s+=r,n.push(s.length))}for(const o of r){let t=s.indexOf(o);for(;-1!==t;)s=s.slice(0,t)+"\0".repeat(o.length)+s.slice(t+o.length),t=s.indexOf(o,t+o.length)}for(const o of e){let e=s.indexOf(o);for(;-1!==e;){if(p(e,o.length,t,n))return!0;e=s.indexOf(o,e+1)}}}return!1}
1
+ const o="ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ",t="ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ",n=" ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ",e={"ㅗㅏ":"ㅘ","ㅗㅐ":"ㅙ","ㅗㅣ":"ㅚ","ㅜㅓ":"ㅝ","ㅜㅔ":"ㅞ","ㅜㅣ":"ㅟ","ㅡㅣ":"ㅢ"},r={"ㄱㅅ":"ㄳ","ㄴㅈ":"ㄵ","ㄴㅎ":"ㄶ","ㄹㄱ":"ㄺ","ㄹㅁ":"ㄻ","ㄹㅂ":"ㄼ","ㄹㅅ":"ㄽ","ㄹㅌ":"ㄾ","ㄹㅍ":"ㄿ","ㄹㅎ":"ㅀ","ㅂㅅ":"ㅄ"},s={r:"ㅏ",i:"ㅣ"},f=o=>{const t={};for(const n of o)for(const o of n.slice(1))t[o]=n[0];return t},i=[9398,119808,119860,119912,120224,120276,120328,120380,120432],c=o=>{for(const t of i)if(o>=t&&o<=t+51)return String.fromCharCode(97+(o-t)%26)},l=f(["a4àáâãäåāăąаα","b8вβ","cçćčс","dďđ","e3èéêëēĕėęěеёε","g69ğ","hн","i1lìíîïīįıłіι","jј","kкκ","mм","nñńň","o0òóôõöøōőоο","pрρ","s5śšşѕ","t7ţťтτ","uùúûüūůűų","xхχ","yýÿу","z2źżž"]),u=f(["a@","c¢(","e€£","i!|¡/","s$§","t+","o°"]),h=/[\p{L}\p{N}]/u,d=o=>void 0!==o&&(t.includes(o)||void 0!==s[o]),p=(f,i,p)=>{const g=[],a=[];for(const e of f.toLowerCase()){let r=e;const s=r.codePointAt(0);s>=65281&&s<=65374?r=String.fromCharCode(s-65248).toLowerCase():s>=4352&&s<=4370?r=o[s-4352]:s>=4449&&s<=4469?r=t[s-4449]:s>=4520&&s<=4546?r=n[s-4519]:s>=9398&&(r=c(s)??r);const f=r>="0"&&r<="9";void 0!==l[r]?(g.push(l[r]),a.push(f)):h.test(r)?(g.push(r),a.push(f)):i&&void 0!==u[r]&&(g.push(u[r]),a.push(!1))}const x=p?((o,t)=>{const n=[],e=o.length;let r=0;for(;r<e;){if(!t[r]){n.push(o[r]),r+=1;continue}let s=r;for(;s<e&&t[s];)s+=1;if(0===r||s===e)for(let t=r;t<s;t+=1)n.push(o[t]);r=s}return n})(g,a):g;for(let o=1,t=x.length;o<t;o+=1)"ㅇ"===x[o]&&x[o-1]>="a"&&x[o-1]<="z"&&(x[o]="o");return(f=>{const i=[],c=f.length;let l=0;for(;l<c;){const u=o.indexOf(f[l]);let h=l+1,p=h<c?t.indexOf(s[f[h]]??f[h]):-1;if(-1===u||-1===p){i.push(f[l]),l+=1;continue}h+=1;const g=h<c?e[t[p]+f[h]]:void 0;void 0!==g&&(p=t.indexOf(g),h+=1);let a=h<c&&!d(f[h+1])?Math.max(n.indexOf(f[h]),0):0;if(a>0){h+=1;const o=h<c?r[n[a]+f[h]]:void 0;void 0===o||d(f[h+1])||(a=n.indexOf(o),h+=1)}i.push(String.fromCharCode(44032+28*(21*u+p)+a)),l=h}return i.join("")})(x).replace(/ㅇ/g,"o")},g=(o,t,n,e)=>{for(let r=0,s=n.length;r<s;r+=1)if(o>=n[r]&&o<e[r])return o===n[r]||o+t<=e[r];return!1},a=[[!0,!1],[!1,!1],[!0,!0],[!1,!0]],x=o=>{const t=[];for(const n of o){if("string"!=typeof n)continue;const o=p(n,!0,!1);o&&t.push(o)}return t};export function hasBadWords(o,t=[],n=[]){if(!o||!t||0===t.length)return!1;const e=x(t);if(0===e.length)return!1;const r=n?x(n):[],s=o.split(/\s+/).filter(o=>""!==o);for(const[o,t]of a){const n=[],f=[];let i="";for(const e of s){const r=p(e,o,t);r&&(n.push(i.length),i+=r,f.push(i.length))}for(const o of r){let t=i.indexOf(o);for(;-1!==t;)i=i.slice(0,t)+"\0".repeat(o.length)+i.slice(t+o.length),t=i.indexOf(o,t+o.length)}for(const o of e){let t=i.indexOf(o);for(;-1!==t;){if(g(t,o.length,n,f))return!0;t=i.indexOf(o,t+1)}}}return!1}
@@ -1 +1 @@
1
- export function is2dArray(r){return r.filter(Array.isArray).length>0}
1
+ export function is2dArray(r){return r.some(Array.isArray)}
@@ -1 +1 @@
1
- export function isEqual(t,...e){const n=e.length>0&&"object"==typeof e[0]?e[0]:e,o=n.length;for(let e=0;e<o;e+=1)if(n[e]!=t)return!1;return!0}
1
+ export function isEqual(r,...t){const n=t.length>0&&Array.isArray(t[0])?t[0]:t,e=n.length;for(let t=0;t<e;t+=1)if(n[t]!=r)return!1;return!0}
@@ -1 +1 @@
1
- export function isEqualStrict(t,...e){const n=e.length>0&&"object"==typeof e[0]?e[0]:e,r=n.length;for(let e=0;e<r;e+=1)if(n[e]!==t)return!1;return!0}
1
+ export function isEqualStrict(r,...t){const n=t.length>0&&Array.isArray(t[0])?t[0]:t,e=n.length;for(let t=0;t<e;t+=1)if(n[t]!==r)return!1;return!0}
@@ -1 +1 @@
1
- export function generateLicense(e){const i=e.htmlBr?"<br/>":"\n",t=`${e.yearStart}${e.yearEnd?`-${e.yearEnd}`:""}`,o=`${e.author}${e.email?` <${e.email}>`:""}`;switch(e.type.replace(/\.-_,\s/g,"").toLowerCase()){case"apache20":return`Copyright ${t} ${o}${i}${i}Licensed under the Apache License, Version 2.0 (the "License");${i}you may not use this file except in compliance with the License.${i}You may obtain a copy of the License at${i}${i} http://www.apache.org/licenses/LICENSE-2.0${i}${i}Unless required by applicable law or agreed to in writing, software${i}distributed under the License is distributed on an "AS IS" BASIS,${i}WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.${i}See the License for the specific language governing permissions and${i}limitations under the License.`;case"bsd3":return`Copyright ${t} ${o}${i}${i}Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:${i}${i}1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.${i}${i}2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.${i}${i}3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.${i}${i}THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.`;default:return`Copyright (c) ${t} ${o}${i}${i}Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:${i}${i}The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.${i}${i}THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`}}
1
+ export function generateLicense(e){const i=e.htmlBr?"<br/>":"\n",t=`${e.yearStart}${e.yearEnd?`-${e.yearEnd}`:""}`,o=`${e.author}${e.email?` <${e.email}>`:""}`;switch(e.type.replace(/[.\-_,\s]/g,"").toLowerCase()){case"apache20":return`Copyright ${t} ${o}${i}${i}Licensed under the Apache License, Version 2.0 (the "License");${i}you may not use this file except in compliance with the License.${i}You may obtain a copy of the License at${i}${i} http://www.apache.org/licenses/LICENSE-2.0${i}${i}Unless required by applicable law or agreed to in writing, software${i}distributed under the License is distributed on an "AS IS" BASIS,${i}WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.${i}See the License for the specific language governing permissions and${i}limitations under the License.`;case"bsd3":return`Copyright ${t} ${o}${i}${i}Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:${i}${i}1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.${i}${i}2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.${i}${i}3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.${i}${i}THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.`;default:return`Copyright (c) ${t} ${o}${i}${i}Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:${i}${i}The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.${i}${i}THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.13.2",
3
+ "version": "1.15.0",
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,13 +73,13 @@
73
73
  ],
74
74
  "devDependencies": {
75
75
  "@eslint/js": "^9.39.2",
76
- "@types/node": "^26.1.1",
76
+ "@types/node": "^26.1.2",
77
77
  "@typescript-eslint/parser": "^8.65.0",
78
78
  "dayjs": "^1.11.21",
79
79
  "eslint": "^9.39.2",
80
80
  "eslint-config-prettier": "^10.1.8",
81
81
  "eslint-plugin-n": "^18.2.2",
82
- "globals": "^17.7.0",
82
+ "globals": "^17.8.0",
83
83
  "jiti": "^2.7.0",
84
84
  "prettier": "^3.9.6",
85
85
  "terser-glob": "^1.2.1",
@@ -1 +0,0 @@
1
- export {};
File without changes
File without changes
File without changes