qsu 1.11.2 → 1.11.3
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/array/arrUnique.js +1 -1
- package/dist/array/arrWithNumber.js +1 -1
- package/dist/array/average.js +1 -1
- package/dist/array/sortByObjectKey.js +1 -1
- package/dist/array/sortNumeric.js +1 -1
- package/dist/format/numberFormat.js +1 -1
- package/dist/math/numUnique.js +1 -1
- package/dist/misc/debounce.js +1 -1
- package/dist/misc/sleep.js +1 -1
- package/dist/node/crypto/objectId.js +1 -1
- package/dist/node/file/getFileHashFromPath.js +1 -1
- package/dist/node/file/headFile.js +1 -1
- package/dist/node/file/isFileHidden.js +1 -1
- package/dist/node/file/tailFile.js +1 -1
- package/dist/node/os/getSid.js +1 -1
- package/dist/node/os/runCommand.js +1 -1
- package/dist/object/objMergeNewKey.js +1 -1
- package/dist/object/objToQueryString.js +1 -1
- package/dist/string/strShuffle.js +1 -1
- package/dist/web/isMatchPathname.js +1 -1
- package/package.json +2 -2
package/dist/array/arrUnique.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{is2dArray as r}from"../verify/is2dArray.js";export function arrUnique(e){return r(e)?Array.from(new Set(e.map(
|
|
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 +1 @@
|
|
|
1
|
-
export function arrWithNumber(r,t){if(r>t)throw new Error("`end` is greater than `start`.");return Array.from({length:t-r+1},(
|
|
1
|
+
export function arrWithNumber(r,t){if(r>t)throw new Error("`end` is greater than `start`.");return Array.from({length:t-r+1},(t,e)=>e+r)}
|
package/dist/array/average.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function average(e){return e.reduce((
|
|
1
|
+
export function average(e){return e.reduce((e,r)=>e+r,0)/e.length}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function sortByObjectKey(r,e,t=!1,o=!1){if(o){const o=new Intl.Collator([],{numeric:!0}),n=r.sort((
|
|
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 +1 @@
|
|
|
1
|
-
export function sortNumeric(r,e=!1){const o=new Intl.Collator([],{numeric:!0}),t=r.sort((
|
|
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 +1 @@
|
|
|
1
|
-
export function numberFormat(t){if(
|
|
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}
|
package/dist/math/numUnique.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function numUnique(){const e=[...Array(89999).keys()].map(
|
|
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)}
|
package/dist/misc/debounce.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function debounce(e,t){let o;return(...u)=>{clearTimeout(o),o=setTimeout((
|
|
1
|
+
export function debounce(e,t){let o;return(...u)=>{clearTimeout(o),o=setTimeout(()=>{e.apply(u)},t)}}
|
package/dist/misc/sleep.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function sleep(e){return new Promise(
|
|
1
|
+
export function sleep(e){return new Promise(t=>{setTimeout(t,e)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function objectId(){return Math.floor(Date.now()/1e3).toString(16)+"x".repeat(16).replace(/x/g,(
|
|
1
|
+
export function objectId(){return Math.floor(Date.now()/1e3).toString(16)+"x".repeat(16).replace(/x/g,()=>Math.floor(16*Math.random()).toString(16))}
|
|
@@ -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((
|
|
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 +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((
|
|
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 +1 @@
|
|
|
1
|
-
import{exec as e}from"child_process";export function isFileHidden(i,r=!1){return new Promise(
|
|
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 +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((
|
|
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))})}
|
package/dist/node/os/getSid.js
CHANGED
|
@@ -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(
|
|
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 +1 @@
|
|
|
1
|
-
import{exec as e}from"child_process";import{EOL as n}from"os";export function runCommand(o){return new Promise((
|
|
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 +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(
|
|
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 +1 @@
|
|
|
1
|
-
export function objToQueryString(e){return Object.keys(e).map(
|
|
1
|
+
export function objToQueryString(e){return Object.keys(e).map(n=>{let o=e[n];return"object"==typeof o&&(o=JSON.stringify(o)),`${encodeURIComponent(n)}=${encodeURIComponent(o)}`}).join("&")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function strShuffle(r){return r?[...r].sort((
|
|
1
|
+
export function strShuffle(r){return r?[...r].sort(()=>Math.random()-.5).join(""):""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function isMatchPathname(t,e){if(!t||!e||e?.length<1)throw new Error("`url` and `matcher` must be set");const r="string"==typeof e?[e]:e,n=t.split("?")[0].replace(/\/$/,"");return r.some(
|
|
1
|
+
export function isMatchPathname(t,e){if(!t||!e||e?.length<1)throw new Error("`url` and `matcher` must be set");const r="string"==typeof e?[e]:e,n=t.split("?")[0].replace(/\/$/,"");return r.some(t=>{if("*"===t||"/*"===t)return!0;const e=t.replace(/\*$/,"");return t.endsWith("*")?n.startsWith(e):e===n})}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qsu",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.3",
|
|
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",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"globals": "^17.4.0",
|
|
84
84
|
"jiti": "^2.6.1",
|
|
85
85
|
"prettier": "^3.8.1",
|
|
86
|
-
"terser-glob": "^1.1
|
|
86
|
+
"terser-glob": "^1.2.1",
|
|
87
87
|
"tsx": "^4.21.0",
|
|
88
88
|
"typescript": "5.9.3",
|
|
89
89
|
"typescript-eslint": "^8.57.2"
|