qsu 1.6.0 → 1.6.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/array.d.ts +1 -1
- package/dist/array.js +1 -1
- package/dist/encrypt.js +1 -0
- package/dist/format.d.ts +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/misc.d.ts +1 -1
- package/dist/object.d.ts +1 -1
- package/dist/object.js +1 -1
- package/dist/string.d.ts +1 -1
- package/dist/string.js +1 -1
- package/package.json +11 -2
- package/dist/crypto.js +0 -1
- /package/dist/{crypto.d.ts → encrypt.d.ts} +0 -0
package/dist/array.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NumberValueObject, PositiveNumber } from './types/global';
|
|
1
|
+
import type { NumberValueObject, PositiveNumber } from './types/global.js';
|
|
2
2
|
export declare function arrShuffle(array: any[]): any[];
|
|
3
3
|
export declare function arrWithDefault(defaultValue: any, length?: number): any[];
|
|
4
4
|
export declare function arrUnique(array: any[]): any[];
|
package/dist/array.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{is2dArray as r,isObject as t}from"./verify";export function arrShuffle(r){if(1===r.length)return r[0];const t=r;for(let e=r.length-1;e>0;e-=1){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[r[n],r[e]]}return t}export function arrWithDefault(r,t=0){return t<1?[]:Array(t).fill(r)}export function arrUnique(t){return r(t)?Array.from(new Set(t.map((r=>JSON.stringify(r)))),(r=>JSON.parse(r))):[...new Set(t)]}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))}export function average(r){return r.reduce(((r,t)=>r+t),0)/r.length}export function arrMove(r,t,e){const n=r.length;if(n<=t||n<=e)throw new Error("Invalid move params");return r.splice(e,0,r.splice(t,1)[0]),r}export function arrTo1dArray(t){const e=t=>{const n=[],o=t.length;for(let u=0;u<o;u+=1)"object"!=typeof t[u]?n.push(t[u]):r(t[u])?n.push(...e(t[u])):n.push(...t[u]);return n};return e(t)}export function arrRepeat(r,e){if(!r||e<1||"object"!=typeof r)return[];const n=t(r),o=[];for(let t=0,u=e;t<u;t+=1)n?o.push(r):o.push(...r);return o}export function arrCount(r){const t={};for(let e=0;e<r.length;e+=1){const n=r[e];t[n]=(t[n]||0)+1}return t}export function sortByObjectKey(r,t,e=!1,n=!1){if(n){const n=new Intl.Collator([],{numeric:!0}),o=r.sort(((r,e)=>n.compare(r[t],e[t])));return e?o.reverse():o}return r.sort(((r,n)=>e?r[t]>n[t]?-1:r[t]<n[t]?1:0:r[t]<n[t]?-1:r[t]>n[t]?1:0))}export function sortNumeric(r,t=!1){const e=new Intl.Collator([],{numeric:!0}),n=r.sort(((r,t)=>e.compare(r,t)));return t?n.reverse():n}export function arrGroupByMaxCount(r,t=1){const e=[],n=r.length;let o=[];for(let u=0;u<n;u+=1)o.length===t&&(e.push(o),o=[]),o.push(r[u]);return o.length>0&&e.push(o),e}
|
|
1
|
+
import{is2dArray as r,isObject as t}from"./verify.js";export function arrShuffle(r){if(1===r.length)return r[0];const t=r;for(let e=r.length-1;e>0;e-=1){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[r[n],r[e]]}return t}export function arrWithDefault(r,t=0){return t<1?[]:Array(t).fill(r)}export function arrUnique(t){return r(t)?Array.from(new Set(t.map((r=>JSON.stringify(r)))),(r=>JSON.parse(r))):[...new Set(t)]}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))}export function average(r){return r.reduce(((r,t)=>r+t),0)/r.length}export function arrMove(r,t,e){const n=r.length;if(n<=t||n<=e)throw new Error("Invalid move params");return r.splice(e,0,r.splice(t,1)[0]),r}export function arrTo1dArray(t){const e=t=>{const n=[],o=t.length;for(let u=0;u<o;u+=1)"object"!=typeof t[u]?n.push(t[u]):r(t[u])?n.push(...e(t[u])):n.push(...t[u]);return n};return e(t)}export function arrRepeat(r,e){if(!r||e<1||"object"!=typeof r)return[];const n=t(r),o=[];for(let t=0,u=e;t<u;t+=1)n?o.push(r):o.push(...r);return o}export function arrCount(r){const t={};for(let e=0;e<r.length;e+=1){const n=r[e];t[n]=(t[n]||0)+1}return t}export function sortByObjectKey(r,t,e=!1,n=!1){if(n){const n=new Intl.Collator([],{numeric:!0}),o=r.sort(((r,e)=>n.compare(r[t],e[t])));return e?o.reverse():o}return r.sort(((r,n)=>e?r[t]>n[t]?-1:r[t]<n[t]?1:0:r[t]<n[t]?-1:r[t]>n[t]?1:0))}export function sortNumeric(r,t=!1){const e=new Intl.Collator([],{numeric:!0}),n=r.sort(((r,t)=>e.compare(r,t)));return t?n.reverse():n}export function arrGroupByMaxCount(r,t=1){const e=[],n=r.length;let o=[];for(let u=0;u<n;u+=1)o.length===t&&(e.push(o),o=[]),o.push(r[u]);return o.length>0&&e.push(o),e}
|
package/dist/encrypt.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomBytes as t,createCipheriv as e,createDecipheriv as r,createHash as n}from"crypto";export function encrypt(r,n,o="aes-256-cbc",f=16,u=!1){if(!r||r.length<1)return"";const a=t(f),c=e(o,n,a);let i=c.update(r);i=Buffer.concat([i,c.final()]);const s=u?"base64":"hex";return`${a.toString(s)}:${i.toString(s)}`}export function decrypt(t,e,n="aes-256-cbc",o=!1){if(!t||t.length<1)return"";const f=o?"base64":"hex",u=t.split(":"),a=r(n,e,Buffer.from(u.shift(),f));let c=a.update(Buffer.from(u.join(":"),f));return c=Buffer.concat([c,a.final()]),c.toString()}export function objectId(){return Math.floor(Date.now()/1e3).toString(16)+"x".repeat(16).replace(/x/g,(()=>Math.floor(16*Math.random()).toString(16)))}export function md5Hash(t){return n("md5").update(t).digest("hex")}export function sha1Hash(t){return n("sha1").update(t).digest("hex")}export function sha256Hash(t){return n("sha256").update(t).digest("hex")}export function encodeBase64(t){return Buffer.from(t,"utf8").toString("base64")}export function decodeBase64(t){return Buffer.from(t,"base64").toString("utf8")}export function strToNumberHash(t){if(!t)return 0;let e=0;for(let r=0;r<t.length;r+=1)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}
|
package/dist/format.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyValueObject, DurationOptions, PositiveNumber } from './types/global';
|
|
1
|
+
import type { AnyValueObject, DurationOptions, PositiveNumber } from './types/global.js';
|
|
2
2
|
export declare function numberFormat(number: number | string): string;
|
|
3
3
|
export declare function fileName(filePath: string, withExtension?: boolean): string;
|
|
4
4
|
export declare function fileSize<N extends number>(bytes: PositiveNumber<N>, decimals?: number): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './array';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './date';
|
|
4
|
-
export * from './format';
|
|
5
|
-
export * from './math';
|
|
6
|
-
export * from './misc';
|
|
7
|
-
export * from './object';
|
|
8
|
-
export * from './string';
|
|
9
|
-
export * from './verify';
|
|
1
|
+
export * from './array.js';
|
|
2
|
+
export * from './encrypt.js';
|
|
3
|
+
export * from './date.js';
|
|
4
|
+
export * from './format.js';
|
|
5
|
+
export * from './math.js';
|
|
6
|
+
export * from './misc.js';
|
|
7
|
+
export * from './object.js';
|
|
8
|
+
export * from './string.js';
|
|
9
|
+
export * from './verify.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./array";export*from"./
|
|
1
|
+
export*from"./array.js";export*from"./encrypt.js";export*from"./date.js";export*from"./format.js";export*from"./math.js";export*from"./misc.js";export*from"./object.js";export*from"./string.js";export*from"./verify.js";
|
package/dist/misc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PositiveNumber } from './types/global';
|
|
1
|
+
import type { PositiveNumber } from './types/global.js';
|
|
2
2
|
export declare function sleep<N extends number>(delay: PositiveNumber<N>): Promise<void>;
|
|
3
3
|
export declare function funcTimes<N extends number>(times: PositiveNumber<N>, iteratee: any): Array<any>;
|
|
4
4
|
export declare function debounce<N extends number>(func: (...args: any[]) => void, timeout: PositiveNumber<N>): (...args: any[]) => void;
|
package/dist/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyValueObject } from './types/global';
|
|
1
|
+
import type { AnyValueObject } from './types/global.js';
|
|
2
2
|
export declare function objToQueryString(obj: AnyValueObject): string;
|
|
3
3
|
export declare function objFindItemRecursiveByKey(obj: AnyValueObject | any[], searchKey: string, searchValue: any, childKey: string): AnyValueObject | null;
|
|
4
4
|
export declare function objToPrettyStr(obj: AnyValueObject): string;
|
package/dist/object.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEmpty as e,isObject as t}from"./verify";export function objToQueryString(e){return Object.keys(e).map((t=>{let r=e[t];return"object"==typeof r&&(r=JSON.stringify(r)),`${encodeURIComponent(t)}=${encodeURIComponent(r)}`})).join("&")}export function objFindItemRecursiveByKey(t,r,n,o){const c=t=>{let s;s="object"==typeof t&&Array.isArray(t)?t:[t];for(let t=0,l=s.length;t<l;t+=1){if(s[t][r]===n)return s[t];if(!e(s[t][o])){const e=c(s[t][o]);if(e)return e}}return null};return c(t)}export function objToPrettyStr(e){return JSON.stringify(e,null,"\t")}export function objToArray(e,r=!1){const n=e=>{const o=[],c=Object.keys(e).length;for(let s=0;s<c;s+=1){const c=Object.keys(e)[s];r&&t(e[c])?o.push([c,n(e[c])]):o.push([c,e[c]])}return o};return n(e)}export function objTo1d(e,r="."){if(!r||r.length<1)throw new Error("`separator` must have value at least 1 character.");const n=(e,o="")=>{let c={};const s=Object.keys(e).length,l=o.length<1;for(let u=0;u<s;u+=1){const s=Object.keys(e)[u],y=e[s],f=`${o}${l?"":r}${s}`;t(y)?(c=Object.assign(c,n(y,f)),delete c[s]):c[f]=y}return c};return n(e)}export function objDeleteKeyByValue(e,r,n=!1){if(!e||"object"!=typeof e)return null;const o=Object.assign(e,{});for(let e=Object.keys(o).length;e>=0;e-=1){const c=Object.keys(o)[e];n&&o[c]&&t(o[c])?objDeleteKeyByValue(o[c],r,n):o[c]===r&&delete o[c]}return o}export function objUpdate(e,r,n,o=!1,c=!1){if(!e||"object"!=typeof e)return null;const s=Object.assign(e,{});let l=!1;const u=e=>{for(let c=0;c<Object.keys(e).length;c+=1){const s=Object.keys(e)[c];o&&e[s]&&t(e[s])&&u(e[s]),Object.hasOwn(e,r)&&(e[r]=n,l=!0)}};return u(s),!l&&c&&(s[r]=n),s}export function objMergeNewKey(e,r){if(!e||"object"!=typeof e||!r||"object"!=typeof r)return null;const n={...e};return Object.keys(r).forEach((e=>{const o=r[e];if(Object.hasOwn(n,e))if(Array.isArray(n[e])&&Array.isArray(o)){if(n[e].length===o.length)for(let r=0;r<n[e].length;r+=1){const c=o[r];t(c)&&(n[e][r]=objMergeNewKey(n[e][r],c))}}else t(n[e])&&t(o)?n[e]=objMergeNewKey(n[e],o):n[e]=o;else n[e]=o})),n}
|
|
1
|
+
import{isEmpty as e,isObject as t}from"./verify.js";export function objToQueryString(e){return Object.keys(e).map((t=>{let r=e[t];return"object"==typeof r&&(r=JSON.stringify(r)),`${encodeURIComponent(t)}=${encodeURIComponent(r)}`})).join("&")}export function objFindItemRecursiveByKey(t,r,n,o){const c=t=>{let s;s="object"==typeof t&&Array.isArray(t)?t:[t];for(let t=0,l=s.length;t<l;t+=1){if(s[t][r]===n)return s[t];if(!e(s[t][o])){const e=c(s[t][o]);if(e)return e}}return null};return c(t)}export function objToPrettyStr(e){return JSON.stringify(e,null,"\t")}export function objToArray(e,r=!1){const n=e=>{const o=[],c=Object.keys(e).length;for(let s=0;s<c;s+=1){const c=Object.keys(e)[s];r&&t(e[c])?o.push([c,n(e[c])]):o.push([c,e[c]])}return o};return n(e)}export function objTo1d(e,r="."){if(!r||r.length<1)throw new Error("`separator` must have value at least 1 character.");const n=(e,o="")=>{let c={};const s=Object.keys(e).length,l=o.length<1;for(let u=0;u<s;u+=1){const s=Object.keys(e)[u],y=e[s],f=`${o}${l?"":r}${s}`;t(y)?(c=Object.assign(c,n(y,f)),delete c[s]):c[f]=y}return c};return n(e)}export function objDeleteKeyByValue(e,r,n=!1){if(!e||"object"!=typeof e)return null;const o=Object.assign(e,{});for(let e=Object.keys(o).length;e>=0;e-=1){const c=Object.keys(o)[e];n&&o[c]&&t(o[c])?objDeleteKeyByValue(o[c],r,n):o[c]===r&&delete o[c]}return o}export function objUpdate(e,r,n,o=!1,c=!1){if(!e||"object"!=typeof e)return null;const s=Object.assign(e,{});let l=!1;const u=e=>{for(let c=0;c<Object.keys(e).length;c+=1){const s=Object.keys(e)[c];o&&e[s]&&t(e[s])&&u(e[s]),Object.hasOwn(e,r)&&(e[r]=n,l=!0)}};return u(s),!l&&c&&(s[r]=n),s}export function objMergeNewKey(e,r){if(!e||"object"!=typeof e||!r||"object"!=typeof r)return null;const n={...e};return Object.keys(r).forEach((e=>{const o=r[e];if(Object.hasOwn(n,e))if(Array.isArray(n[e])&&Array.isArray(o)){if(n[e].length===o.length)for(let r=0;r<n[e].length;r+=1){const c=o[r];t(c)&&(n[e][r]=objMergeNewKey(n[e][r],c))}}else t(n[e])&&t(o)?n[e]=objMergeNewKey(n[e],o):n[e]=o;else n[e]=o})),n}
|
package/dist/string.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PositiveNumber } from './types/global';
|
|
1
|
+
import type { PositiveNumber } from './types/global.js';
|
|
2
2
|
export declare function trim(str?: string | null): string | null;
|
|
3
3
|
export declare function removeSpecialChar(str: string, exceptionCharacters?: string): string;
|
|
4
4
|
export declare function replaceBetween(str: string, startChar: string, endChar: string, replaceWith?: string): string;
|
package/dist/string.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contains as t}from"./verify";import{numRandom as e}from"./math";export function trim(t){return"string"==typeof t||t?t.trim().replace(/\s{2,}/g," "):null}export function removeSpecialChar(t,e){return t?t.replace(new RegExp(`[^a-zA-Z가-힣ㄱ-ㅎㅏ-ㅣ0-9-ヿ㐀-䶿一-鿿豈-ヲ-゚${e??""}]`,"gi"),""):""}export function replaceBetween(t,e,r,n=""){if(!t)return"";const o=/[.*+?^${}()|[\]\\]/g,i=o.test(e)?`\\${e}`:e,l=o.test(r)?`\\${r}`:r;return t.replace(new RegExp(`${i}.*?${l}`,"g"),n)}export function removeNewLine(t,e=""){return t?t.replace(/(\r\n|\n|\r)/gm,e).trim():""}export function capitalizeFirst(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}export function capitalizeEverySentence(t,e){if(!t)return"";const r=e||".",n=t.split(r);let o,i="";for(let t=0,e=n.length;t<e;t+=1){o=[...n[t]];for(let e=0,r=o.length;e<r;e+=1)if(/[a-zA-Z]/.test(n[t][e])){o[e]=n[t][e].toUpperCase();break}i+=`${o.join("")}${t<e-1?r:""}`}return i}export function capitalizeEachWords(e,r){if(!e)return"";const n=e.trim().toLowerCase().split(" ");for(let e=0,o=n.length;e<o;e+=1)r&&t(n[e],["in","on","the","at","and","or","of","for","to","that","a","by","it","is","as","are","were","was","nor","an"],!0)||(n[e]=capitalizeFirst(n[e]));return capitalizeFirst(n.join(" "))}export function strCount(t,e){if(!t||!e)return 0;let r=0,n=t.indexOf(e);for(;n>-1;)r+=1,n=t.indexOf(e,n+=e.length);return r}export function strShuffle(t){return t?[...t].sort((()=>Math.random()-.5)).join(""):""}export function strRandom(t,e){const r=`abcdefghijklmnopqrstuvwxyz0123456789${e}`,n=r.length;let o,i="";for(let e=0;e<t;e+=1)o=r.charAt(Math.floor(Math.random()*n)),o=Math.random()<.5?o.toUpperCase():o,i+=o;return i}export function strBlindRandom(t,r,n="*"){if(!t)return"";let o=t,i=0,l=0,a=0;const c=o.length;for(;i<r&&a<c;)l=e(0,c),/[a-zA-Z가-힣]/.test(o.substring(l,l+1))&&(o=`${o.substring(0,l+1)}${n}${o.substring(l+2)}`,i+=1),a+=1;return o}export function truncate(t,e,r=""){if(!t)return"";let n=t;return t.length>e&&(n=t.substring(0,e)+r),n}export function truncateExpect(t,e,r="."){if(!t)return"";const n=t.slice(-1)===r,o=t.split(r),i=o.length;let l="",a=0;for(let t=0;t<i&&a<e;t+=1)l+=`${o[t]}${t!==i-1||n?r:""}`,a+=o[t].length+r.length;return l}export function split(t,...e){if(!t)return[];const r=e.length>0&&"object"==typeof e[0]?e[0]:e,n=r.length;let o="",i="";for(let t=0;t<n;t+=1){const e=r[t];e.length>1?i+=`${i.length<1?"":"|"}${e.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/]/g,"\\]").replace(/\?/g,"\\?").replace(/\./g,"\\.").replace(/\{/g,"\\{").replace(/}/g,"\\}").replace(/\+/g,"\\+")}`:o+="-"===e||"["===e||"]"===e?`\\${e}`:e}return o.length<1&&i.length<1?[t]:(o.length>0&&(o=`[${o}]`,i.length>0&&(i=`|${i}`)),t.split(new RegExp(`${o}${i}+`,"gi")))}export function strToAscii(t){const e=[];for(let r=0;r<t.length;r+=1)e.push(t.charCodeAt(r));return e}export function strUnique(t){return t?[...new Set(t)].join(""):""}export function urlJoin(...t){if(!t)return"";const e=t.length;let r="",n=0;for(let o=0;o<e;o+=1)null!==t[o]&&void 0!==t[o]&&(0===n||t[o].startsWith("/")||t[o].startsWith("?")||t[o].startsWith("&")?r+=t[o]:r+=`/${t[o]}`,n+=1);return r.replace(/\/$/g,"")}
|
|
1
|
+
import{contains as t}from"./verify.js";import{numRandom as e}from"./math.js";export function trim(t){return"string"==typeof t||t?t.trim().replace(/\s{2,}/g," "):null}export function removeSpecialChar(t,e){return t?t.replace(new RegExp(`[^a-zA-Z가-힣ㄱ-ㅎㅏ-ㅣ0-9-ヿ㐀-䶿一-鿿豈-ヲ-゚${e??""}]`,"gi"),""):""}export function replaceBetween(t,e,r,n=""){if(!t)return"";const o=/[.*+?^${}()|[\]\\]/g,i=o.test(e)?`\\${e}`:e,l=o.test(r)?`\\${r}`:r;return t.replace(new RegExp(`${i}.*?${l}`,"g"),n)}export function removeNewLine(t,e=""){return t?t.replace(/(\r\n|\n|\r)/gm,e).trim():""}export function capitalizeFirst(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}export function capitalizeEverySentence(t,e){if(!t)return"";const r=e||".",n=t.split(r);let o,i="";for(let t=0,e=n.length;t<e;t+=1){o=[...n[t]];for(let e=0,r=o.length;e<r;e+=1)if(/[a-zA-Z]/.test(n[t][e])){o[e]=n[t][e].toUpperCase();break}i+=`${o.join("")}${t<e-1?r:""}`}return i}export function capitalizeEachWords(e,r){if(!e)return"";const n=e.trim().toLowerCase().split(" ");for(let e=0,o=n.length;e<o;e+=1)r&&t(n[e],["in","on","the","at","and","or","of","for","to","that","a","by","it","is","as","are","were","was","nor","an"],!0)||(n[e]=capitalizeFirst(n[e]));return capitalizeFirst(n.join(" "))}export function strCount(t,e){if(!t||!e)return 0;let r=0,n=t.indexOf(e);for(;n>-1;)r+=1,n=t.indexOf(e,n+=e.length);return r}export function strShuffle(t){return t?[...t].sort((()=>Math.random()-.5)).join(""):""}export function strRandom(t,e){const r=`abcdefghijklmnopqrstuvwxyz0123456789${e}`,n=r.length;let o,i="";for(let e=0;e<t;e+=1)o=r.charAt(Math.floor(Math.random()*n)),o=Math.random()<.5?o.toUpperCase():o,i+=o;return i}export function strBlindRandom(t,r,n="*"){if(!t)return"";let o=t,i=0,l=0,a=0;const c=o.length;for(;i<r&&a<c;)l=e(0,c),/[a-zA-Z가-힣]/.test(o.substring(l,l+1))&&(o=`${o.substring(0,l+1)}${n}${o.substring(l+2)}`,i+=1),a+=1;return o}export function truncate(t,e,r=""){if(!t)return"";let n=t;return t.length>e&&(n=t.substring(0,e)+r),n}export function truncateExpect(t,e,r="."){if(!t)return"";const n=t.slice(-1)===r,o=t.split(r),i=o.length;let l="",a=0;for(let t=0;t<i&&a<e;t+=1)l+=`${o[t]}${t!==i-1||n?r:""}`,a+=o[t].length+r.length;return l}export function split(t,...e){if(!t)return[];const r=e.length>0&&"object"==typeof e[0]?e[0]:e,n=r.length;let o="",i="";for(let t=0;t<n;t+=1){const e=r[t];e.length>1?i+=`${i.length<1?"":"|"}${e.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/]/g,"\\]").replace(/\?/g,"\\?").replace(/\./g,"\\.").replace(/\{/g,"\\{").replace(/}/g,"\\}").replace(/\+/g,"\\+")}`:o+="-"===e||"["===e||"]"===e?`\\${e}`:e}return o.length<1&&i.length<1?[t]:(o.length>0&&(o=`[${o}]`,i.length>0&&(i=`|${i}`)),t.split(new RegExp(`${o}${i}+`,"gi")))}export function strToAscii(t){const e=[];for(let r=0;r<t.length;r+=1)e.push(t.charCodeAt(r));return e}export function strUnique(t){return t?[...new Set(t)].join(""):""}export function urlJoin(...t){if(!t)return"";const e=t.length;let r="",n=0;for(let o=0;o<e;o+=1)null!==t[o]&&void 0!==t[o]&&(0===n||t[o].startsWith("/")||t[o].startsWith("?")||t[o].startsWith("&")?r+=t[o]:r+=`/${t[o]}`,n+=1);return r.replace(/\/$/g,"")}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qsu",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.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 NodeJS projects.",
|
|
5
5
|
"author": "Jooy2 <jooy2.contact@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,16 @@
|
|
|
29
29
|
},
|
|
30
30
|
"main": "dist/index.js",
|
|
31
31
|
"exports": {
|
|
32
|
-
".":
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"module": "./dist/index.js",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./types": {
|
|
38
|
+
"types": "./dist/types/global.d.ts",
|
|
39
|
+
"module": "./dist/types/global.js",
|
|
40
|
+
"default": "./dist/types/global.js"
|
|
41
|
+
}
|
|
33
42
|
},
|
|
34
43
|
"typesVersions": {
|
|
35
44
|
"*": {
|
package/dist/crypto.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{randomBytes as t,createCipheriv as e,createDecipheriv as r,createHash as n}from"node:crypto";export function encrypt(r,n,o="aes-256-cbc",f=16,u=!1){if(!r||r.length<1)return"";const a=t(f),c=e(o,n,a);let i=c.update(r);i=Buffer.concat([i,c.final()]);const s=u?"base64":"hex";return`${a.toString(s)}:${i.toString(s)}`}export function decrypt(t,e,n="aes-256-cbc",o=!1){if(!t||t.length<1)return"";const f=o?"base64":"hex",u=t.split(":"),a=r(n,e,Buffer.from(u.shift(),f));let c=a.update(Buffer.from(u.join(":"),f));return c=Buffer.concat([c,a.final()]),c.toString()}export function objectId(){return Math.floor(Date.now()/1e3).toString(16)+"x".repeat(16).replace(/x/g,(()=>Math.floor(16*Math.random()).toString(16)))}export function md5Hash(t){return n("md5").update(t).digest("hex")}export function sha1Hash(t){return n("sha1").update(t).digest("hex")}export function sha256Hash(t){return n("sha256").update(t).digest("hex")}export function encodeBase64(t){return Buffer.from(t,"utf8").toString("base64")}export function decodeBase64(t){return Buffer.from(t,"base64").toString("utf8")}export function strToNumberHash(t){if(!t)return 0;let e=0;for(let r=0;r<t.length;r+=1)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}
|
|
File without changes
|