qsu 1.15.0 → 1.16.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.
@@ -15,6 +15,15 @@ export type DurationOptions = {
15
15
  maxUnitCount?: number;
16
16
  unit?: DurationUnitName;
17
17
  };
18
+ export type RetryOptions = {
19
+ times?: number;
20
+ delay?: number;
21
+ backoff?: number;
22
+ };
23
+ export type ThrottleOptions = {
24
+ leading?: boolean;
25
+ trailing?: boolean;
26
+ };
18
27
  export interface FileInfo {
19
28
  success: boolean;
20
29
  isDirectory: boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * (Private, not exported from the package) A stable string key for a value, so that array
3
+ * membership can be decided by value instead of by reference.
4
+ *
5
+ * Python cannot hash a list or a dict at all, so a reference comparison could not have been
6
+ * ported to all three languages. Comparing by value also means `arrDifference([[1]], [[1]])`
7
+ * answers the same way everywhere.
8
+ */
9
+ export declare function comparableKey(value: any): string;
@@ -0,0 +1 @@
1
+ export function comparableKey(n){if(null===n)return"null";if(void 0===n)return"undefined";const r=typeof n;if("number"===r)return Number.isNaN(n)?"number:NaN":`number:${0===n?0:n}`;if("string"===r||"boolean"===r||"bigint"===r)return`${r}:${n}`;if("function"===r||"symbol"===r)return`${r}:${String(n)}`;try{return`json:${JSON.stringify(n)}`}catch{return`json:${String(n)}`}}
@@ -0,0 +1 @@
1
+ export declare function arrCompact(array: any[]): any[];
@@ -0,0 +1 @@
1
+ export function arrCompact(r){if(!Array.isArray(r))return[];const t=[];for(let n=0,e=r.length;n<e;n+=1){const e=r[n];null==e||!1===e||0===e||""===e||"number"==typeof e&&Number.isNaN(e)||t.push(e)}return t}
@@ -0,0 +1 @@
1
+ export declare function arrDifference(array: any[], ...others: any[][]): any[];
@@ -0,0 +1 @@
1
+ import{comparableKey as r}from"./_comparableKey.js";export function arrDifference(e,...t){if(!Array.isArray(e))return[];const n=new Set;for(let e=0,a=t.length;e<a;e+=1){const a=t[e];if(Array.isArray(a))for(let e=0,t=a.length;e<t;e+=1)n.add(r(a[e]))}return e.filter(e=>!n.has(r(e)))}
@@ -0,0 +1 @@
1
+ export declare function arrIntersection(...arrays: any[][]): any[];
@@ -0,0 +1 @@
1
+ import{comparableKey as r}from"./_comparableKey.js";export function arrIntersection(...e){if(e.length<1||!Array.isArray(e[0]))return[];const[t,...n]=e,a=[];for(let e=0,t=n.length;e<t;e+=1){if(!Array.isArray(n[e]))return[];a.push(new Set(n[e].map(r)))}const o=new Set,s=[];for(let e=0,n=t.length;e<n;e+=1){const n=t[e],h=r(n);o.has(h)||(o.add(h),a.every(r=>r.has(h))&&s.push(n))}return s}
@@ -1,5 +1,8 @@
1
+ export { arrCompact } from './arrCompact.js';
1
2
  export { arrCount } from './arrCount.js';
3
+ export { arrDifference } from './arrDifference.js';
2
4
  export { arrGroupByMaxCount } from './arrGroupByMaxCount.js';
5
+ export { arrIntersection } from './arrIntersection.js';
3
6
  export { arrMove } from './arrMove.js';
4
7
  export { arrPick } from './arrPick.js';
5
8
  export { arrRepeat } from './arrRepeat.js';
@@ -1 +1 @@
1
- export{arrCount}from"./arrCount.js";export{arrGroupByMaxCount}from"./arrGroupByMaxCount.js";export{arrMove}from"./arrMove.js";export{arrPick}from"./arrPick.js";export{arrRepeat}from"./arrRepeat.js";export{arrShuffle}from"./arrShuffle.js";export{arrTo1dArray}from"./arrTo1dArray.js";export{arrUnique}from"./arrUnique.js";export{arrWithDefault}from"./arrWithDefault.js";export{arrWithNumber}from"./arrWithNumber.js";export{average}from"./average.js";export{sortByObjectKey}from"./sortByObjectKey.js";export{sortNumeric}from"./sortNumeric.js";
1
+ export{arrCompact}from"./arrCompact.js";export{arrCount}from"./arrCount.js";export{arrDifference}from"./arrDifference.js";export{arrGroupByMaxCount}from"./arrGroupByMaxCount.js";export{arrIntersection}from"./arrIntersection.js";export{arrMove}from"./arrMove.js";export{arrPick}from"./arrPick.js";export{arrRepeat}from"./arrRepeat.js";export{arrShuffle}from"./arrShuffle.js";export{arrTo1dArray}from"./arrTo1dArray.js";export{arrUnique}from"./arrUnique.js";export{arrWithDefault}from"./arrWithDefault.js";export{arrWithNumber}from"./arrWithNumber.js";export{average}from"./average.js";export{sortByObjectKey}from"./sortByObjectKey.js";export{sortNumeric}from"./sortNumeric.js";
@@ -1,3 +1,5 @@
1
1
  export { debounce } from './debounce.js';
2
2
  export { funcTimes } from './funcTimes.js';
3
+ export { retry } from './retry.js';
3
4
  export { sleep } from './sleep.js';
5
+ export { throttle } from './throttle.js';
@@ -1 +1 @@
1
- export{debounce}from"./debounce.js";export{funcTimes}from"./funcTimes.js";export{sleep}from"./sleep.js";
1
+ export{debounce}from"./debounce.js";export{funcTimes}from"./funcTimes.js";export{retry}from"./retry.js";export{sleep}from"./sleep.js";export{throttle}from"./throttle.js";
@@ -0,0 +1,2 @@
1
+ import type { RetryOptions } from '../_types/global';
2
+ export declare function retry<T>(func: () => T | Promise<T>, options?: RetryOptions): Promise<T>;
@@ -0,0 +1 @@
1
+ import{sleep as t}from"./sleep.js";export async function retry(r,e){const a=e?.times??3,o=e?.delay??0,s=e?.backoff??1;if(a<1)throw new Error("`times` must be at least 1.");let i,c=o;for(let e=1;e<=a;e+=1)try{return await r()}catch(r){i=r,e<a&&(c>0&&await t(c),c*=s)}throw i}
@@ -0,0 +1,2 @@
1
+ import type { PositiveNumber, ThrottleOptions } from '../_types/global';
2
+ export declare function throttle<N extends number>(func: (...args: any[]) => void, wait: PositiveNumber<N>, options?: ThrottleOptions): (...args: any[]) => void;
@@ -0,0 +1 @@
1
+ export function throttle(n,l,t){const o=t?.leading??!0,e=t?.trailing??!0;let u,i=null,r=null;const c=()=>{i=o?Date.now():null,u=void 0;const l=r;r=null,l&&n(...l)};return(...t)=>{const s=Date.now();null!==i||o||(i=s);const a=null===i?0:l-(s-i);if(r=t,a<=0||a>l)return u&&(clearTimeout(u),u=void 0),i=s,r=null,void n(...t);!u&&e&&(u=setTimeout(c,a),u?.unref?.())}}
@@ -1,6 +1,9 @@
1
1
  export { objDeleteKeyByValue } from './objDeleteKeyByValue.js';
2
2
  export { objFindItemRecursiveByKey } from './objFindItemRecursiveByKey.js';
3
+ export { objInvert } from './objInvert.js';
4
+ export { objMapKeys } from './objMapKeys.js';
3
5
  export { objMergeNewKey } from './objMergeNewKey.js';
6
+ export { objPickBy } from './objPickBy.js';
4
7
  export { objTo1d } from './objTo1d.js';
5
8
  export { objToArray } from './objToArray.js';
6
9
  export { objToPrettyStr } from './objToPrettyStr.js';
@@ -1 +1 @@
1
- export{objDeleteKeyByValue}from"./objDeleteKeyByValue.js";export{objFindItemRecursiveByKey}from"./objFindItemRecursiveByKey.js";export{objMergeNewKey}from"./objMergeNewKey.js";export{objTo1d}from"./objTo1d.js";export{objToArray}from"./objToArray.js";export{objToPrettyStr}from"./objToPrettyStr.js";export{objToQueryString}from"./objToQueryString.js";export{objUpdate}from"./objUpdate.js";
1
+ export{objDeleteKeyByValue}from"./objDeleteKeyByValue.js";export{objFindItemRecursiveByKey}from"./objFindItemRecursiveByKey.js";export{objInvert}from"./objInvert.js";export{objMapKeys}from"./objMapKeys.js";export{objMergeNewKey}from"./objMergeNewKey.js";export{objPickBy}from"./objPickBy.js";export{objTo1d}from"./objTo1d.js";export{objToArray}from"./objToArray.js";export{objToPrettyStr}from"./objToPrettyStr.js";export{objToQueryString}from"./objToQueryString.js";export{objUpdate}from"./objUpdate.js";
@@ -0,0 +1,4 @@
1
+ import type { AnyValueObject } from '../_types/global';
2
+ export declare function objInvert(obj: AnyValueObject): {
3
+ [key: string]: string;
4
+ } | null;
@@ -0,0 +1 @@
1
+ export function objInvert(t){if(!t||"object"!=typeof t)return null;const e={},n=Object.keys(t);for(let o=0,r=n.length;o<r;o+=1){const r=n[o];e[String(t[r])]=r}return e}
@@ -0,0 +1,2 @@
1
+ import type { AnyValueObject } from '../_types/global';
2
+ export declare function objMapKeys(obj: AnyValueObject, iteratee: (value: any, key: string) => string): AnyValueObject | null;
@@ -0,0 +1 @@
1
+ export function objMapKeys(t,e){if(!t||"object"!=typeof t)return null;const n={},o=Object.keys(t);for(let r=0,c=o.length;r<c;r+=1){const c=o[r];n[e(t[c],c)]=t[c]}return n}
@@ -0,0 +1,2 @@
1
+ import type { AnyValueObject } from '../_types/global';
2
+ export declare function objPickBy(obj: AnyValueObject, predicate: (value: any, key: string) => boolean): AnyValueObject | null;
@@ -0,0 +1 @@
1
+ export function objPickBy(t,e){if(!t||"object"!=typeof t)return null;const n={},o=Object.keys(t);for(let c=0,r=o.length;c<r;c+=1){const r=o[c];e(t[r],r)&&(n[r]=t[r])}return n}
@@ -0,0 +1 @@
1
+ export declare function deburr(str: string): string;
@@ -0,0 +1 @@
1
+ const t=[["ÀÁÂÃÄÅĀĂĄ","A"],["àáâãäåāăą","a"],["ÇĆĈĊČ","C"],["çćĉċč","c"],["ÐĎĐ","D"],["ðďđ","d"],["ÈÉÊËĒĔĖĘĚ","E"],["èéêëēĕėęě","e"],["ĜĞĠĢ","G"],["ĝğġģ","g"],["ĤĦ","H"],["ĥħ","h"],["ÌÍÎÏĨĪĬĮİ","I"],["ìíîïĩīĭįı","i"],["Ĵ","J"],["ĵ","j"],["Ķ","K"],["ķĸ","k"],["ĹĻĽĿŁ","L"],["ĺļľŀł","l"],["ÑŃŅŇŊ","N"],["ñńņňŋ","n"],["ÒÓÔÕÖØŌŎŐ","O"],["òóôõöøōŏő","o"],["ŔŖŘ","R"],["ŕŗř","r"],["ŚŜŞŠ","S"],["śŝşšſ","s"],["ŢŤŦ","T"],["ţťŧ","t"],["ÙÚÛÜŨŪŬŮŰŲ","U"],["ùúûüũūŭůűų","u"],["Ŵ","W"],["ŵ","w"],["ÝŶŸ","Y"],["ýÿŷ","y"],["ŹŻŽ","Z"],["źżž","z"],["Æ","Ae"],["æ","ae"],["Þ","Th"],["þ","th"],["ß","ss"],["IJ","IJ"],["ij","ij"],["Œ","Oe"],["œ","oe"],["ʼn","'n"]],e=new Map;for(let n=0,r=t.length;n<r;n+=1){const[s,c]=t[n];for(const f of s)e.set(f,c)}const o=t=>t>=768&&t<=879||t>=8400&&t<=8432||t>=65056&&t<=65071;export function deburr(t){if(!t)return"";let n="";for(const r of t)o(r.codePointAt(0))||(n+=e.get(r)??r);return n}
@@ -0,0 +1 @@
1
+ export declare function escapeRegExp(str: string): string;
@@ -0,0 +1 @@
1
+ const e=/[\\^$.*+?()[\]{}|]/g;export function escapeRegExp(c){return c?c.replace(e,"\\$&"):""}
@@ -1,6 +1,8 @@
1
1
  export { capitalizeEachWords } from './capitalizeEachWords.js';
2
2
  export { capitalizeEverySentence } from './capitalizeEverySentence.js';
3
3
  export { capitalizeFirst } from './capitalizeFirst.js';
4
+ export { deburr } from './deburr.js';
5
+ export { escapeRegExp } from './escapeRegExp.js';
4
6
  export { getGroupKeys } from './getGroupKeys.js';
5
7
  export { getStrBytes } from './getStrBytes.js';
6
8
  export { removeNewLine } from './removeNewLine.js';
@@ -16,4 +18,6 @@ export { strUnique } from './strUnique.js';
16
18
  export { trim } from './trim.js';
17
19
  export { truncate } from './truncate.js';
18
20
  export { truncateExpect } from './truncateExpect.js';
21
+ export { uncapitalizeFirst } from './uncapitalizeFirst.js';
19
22
  export { urlJoin } from './urlJoin.js';
23
+ export { words } from './words.js';
@@ -1 +1 @@
1
- export{capitalizeEachWords}from"./capitalizeEachWords.js";export{capitalizeEverySentence}from"./capitalizeEverySentence.js";export{capitalizeFirst}from"./capitalizeFirst.js";export{getGroupKeys}from"./getGroupKeys.js";export{getStrBytes}from"./getStrBytes.js";export{removeNewLine}from"./removeNewLine.js";export{removeSpecialChar}from"./removeSpecialChar.js";export{replaceBetween}from"./replaceBetween.js";export{split}from"./split.js";export{strBlindRandom}from"./strBlindRandom.js";export{strCount}from"./strCount.js";export{strRandom}from"./strRandom.js";export{strShuffle}from"./strShuffle.js";export{strToAscii}from"./strToAscii.js";export{strUnique}from"./strUnique.js";export{trim}from"./trim.js";export{truncate}from"./truncate.js";export{truncateExpect}from"./truncateExpect.js";export{urlJoin}from"./urlJoin.js";
1
+ export{capitalizeEachWords}from"./capitalizeEachWords.js";export{capitalizeEverySentence}from"./capitalizeEverySentence.js";export{capitalizeFirst}from"./capitalizeFirst.js";export{deburr}from"./deburr.js";export{escapeRegExp}from"./escapeRegExp.js";export{getGroupKeys}from"./getGroupKeys.js";export{getStrBytes}from"./getStrBytes.js";export{removeNewLine}from"./removeNewLine.js";export{removeSpecialChar}from"./removeSpecialChar.js";export{replaceBetween}from"./replaceBetween.js";export{split}from"./split.js";export{strBlindRandom}from"./strBlindRandom.js";export{strCount}from"./strCount.js";export{strRandom}from"./strRandom.js";export{strShuffle}from"./strShuffle.js";export{strToAscii}from"./strToAscii.js";export{strUnique}from"./strUnique.js";export{trim}from"./trim.js";export{truncate}from"./truncate.js";export{truncateExpect}from"./truncateExpect.js";export{uncapitalizeFirst}from"./uncapitalizeFirst.js";export{urlJoin}from"./urlJoin.js";export{words}from"./words.js";
@@ -0,0 +1 @@
1
+ export declare function uncapitalizeFirst(str: string): string;
@@ -0,0 +1 @@
1
+ export function uncapitalizeFirst(t){return t?t.charAt(0).toLowerCase()+t.slice(1):""}
@@ -0,0 +1 @@
1
+ export declare function words(str: string): string[];
@@ -0,0 +1 @@
1
+ const e=/\p{L}/u,t=/\p{M}/u,s=/\p{Lu}|\p{Lt}/u,o=/\p{Ll}/u,r=e=>e>="0"&&e<="9",f=t=>e.test(t),i=e=>t.test(e),l=e=>s.test(e),n=e=>o.test(e),u=e=>l(e)||n(e);export function words(e){if(!e)return[];const t=Array.from(e),s=t.length,o=[];let p=0;for(;p<s;){const e=t[p];let c=p+1;if(r(e)){for(;c<s&&r(t[c]);)c+=1;o.push(t.slice(p,c).join("")),p=c}else if(f(e)){if(u(e))if(l(e)){for(;c<s&&f(t[c])&&l(t[c]);)c+=1;if(c-p>1)c<s&&f(t[c])&&n(t[c])&&(c-=1);else for(;c<s&&(i(t[c])||f(t[c])&&n(t[c]));)c+=1}else for(;c<s&&(i(t[c])||f(t[c])&&n(t[c]));)c+=1;else for(;c<s&&(i(t[c])||f(t[c])&&!u(t[c]));)c+=1;o.push(t.slice(p,c).join("")),p=c}else p+=1}return o}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.15.0",
3
+ "version": "1.16.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",
@@ -74,17 +74,17 @@
74
74
  "devDependencies": {
75
75
  "@eslint/js": "^9.39.2",
76
76
  "@types/node": "^26.1.2",
77
- "@typescript-eslint/parser": "^8.65.0",
77
+ "@typescript-eslint/parser": "^8.66.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.8.0",
82
+ "globals": "^17.9.0",
83
83
  "jiti": "^2.7.0",
84
84
  "prettier": "^3.9.6",
85
85
  "terser-glob": "^1.2.1",
86
- "tsx": "^4.23.1",
86
+ "tsx": "^4.23.5",
87
87
  "typescript": "6.0.3",
88
- "typescript-eslint": "^8.65.0"
88
+ "typescript-eslint": "^8.66.0"
89
89
  }
90
90
  }