qsu 1.16.0 → 1.17.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 (50) hide show
  1. package/dist/_types/global.d.ts +4 -0
  2. package/dist/math/_decimalShift.d.ts +10 -0
  3. package/dist/math/_decimalShift.js +1 -0
  4. package/dist/math/ceil.d.ts +1 -0
  5. package/dist/math/ceil.js +1 -0
  6. package/dist/math/clamp.d.ts +1 -0
  7. package/dist/math/clamp.js +1 -0
  8. package/dist/math/floor.d.ts +1 -0
  9. package/dist/math/floor.js +1 -0
  10. package/dist/math/index.d.ts +6 -0
  11. package/dist/math/index.js +1 -1
  12. package/dist/math/max.d.ts +2 -0
  13. package/dist/math/max.js +1 -0
  14. package/dist/math/min.d.ts +2 -0
  15. package/dist/math/min.js +1 -0
  16. package/dist/math/round.d.ts +1 -0
  17. package/dist/math/round.js +1 -0
  18. package/dist/object/index.d.ts +4 -0
  19. package/dist/object/index.js +1 -1
  20. package/dist/object/objClone.d.ts +3 -0
  21. package/dist/object/objClone.js +1 -0
  22. package/dist/object/objGet.d.ts +4 -0
  23. package/dist/object/objGet.js +1 -0
  24. package/dist/object/objMerge.d.ts +2 -0
  25. package/dist/object/objMerge.js +1 -0
  26. package/dist/object/objPick.d.ts +2 -0
  27. package/dist/object/objPick.js +1 -0
  28. package/dist/string/_capitalizeWord.d.ts +10 -0
  29. package/dist/string/_capitalizeWord.js +1 -0
  30. package/dist/string/index.d.ts +6 -0
  31. package/dist/string/index.js +1 -1
  32. package/dist/string/pad.d.ts +2 -0
  33. package/dist/string/pad.js +1 -0
  34. package/dist/string/strToCamelCase.d.ts +1 -0
  35. package/dist/string/strToCamelCase.js +1 -0
  36. package/dist/string/strToConstantCase.d.ts +1 -0
  37. package/dist/string/strToConstantCase.js +1 -0
  38. package/dist/string/strToKebabCase.d.ts +1 -0
  39. package/dist/string/strToKebabCase.js +1 -0
  40. package/dist/string/strToPascalCase.d.ts +1 -0
  41. package/dist/string/strToPascalCase.js +1 -0
  42. package/dist/string/strToSnakeCase.d.ts +1 -0
  43. package/dist/string/strToSnakeCase.js +1 -0
  44. package/dist/web/escapeHtml.d.ts +1 -0
  45. package/dist/web/escapeHtml.js +1 -0
  46. package/dist/web/index.d.ts +2 -0
  47. package/dist/web/index.js +1 -1
  48. package/dist/web/unescapeHtml.d.ts +1 -0
  49. package/dist/web/unescapeHtml.js +1 -0
  50. package/package.json +2 -2
@@ -20,6 +20,10 @@ export type RetryOptions = {
20
20
  delay?: number;
21
21
  backoff?: number;
22
22
  };
23
+ export type PadOptions = {
24
+ position?: 'start' | 'end' | 'both';
25
+ char?: string;
26
+ };
23
27
  export type ThrottleOptions = {
24
28
  leading?: boolean;
25
29
  trailing?: boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * (Private, not exported from the package) Multiplies a number by a power of ten by moving
3
+ * the exponent of its shortest string representation, instead of multiplying by `10 ** n`.
4
+ *
5
+ * `1.005 * 100` is `100.49999999999999`, so the naive form answers `1` for `round(1.005, 2)`
6
+ * and `1.1 * 10` is `11.000000000000002`, so `ceil(1.1, 1)` answers `1.2`. Parsing
7
+ * `'1.005e2'` yields exactly `100.5` instead, because the shortest representation is the
8
+ * decimal the caller wrote and the parser rounds it to the nearest double exactly once.
9
+ */
10
+ export declare function decimalShift(value: number, exponent: number): number;
@@ -0,0 +1 @@
1
+ export function decimalShift(e,t){const[r,i]=String(e).split("e");return Number(`${r}e${(i?Number(i):0)+t}`)}
@@ -0,0 +1 @@
1
+ export declare function ceil(value: number, precision?: number): number;
@@ -0,0 +1 @@
1
+ import{decimalShift as i}from"./_decimalShift.js";export function ceil(e,t=0){return Number.isFinite(e)?i(Math.ceil(i(e,t)),-t):e}
@@ -0,0 +1 @@
1
+ export declare function clamp(value: number, min: number, max: number): number;
@@ -0,0 +1 @@
1
+ export function clamp(t,a,n){return Math.max(Math.min(t,n),a)}
@@ -0,0 +1 @@
1
+ export declare function floor(value: number, precision?: number): number;
@@ -0,0 +1 @@
1
+ import{decimalShift as o}from"./_decimalShift.js";export function floor(r,i=0){return Number.isFinite(r)?o(Math.floor(o(r,i)),-i):r}
@@ -1,6 +1,12 @@
1
+ export { ceil } from './ceil.js';
2
+ export { clamp } from './clamp.js';
1
3
  export { div } from './div.js';
4
+ export { floor } from './floor.js';
5
+ export { max } from './max.js';
6
+ export { min } from './min.js';
2
7
  export { mul } from './mul.js';
3
8
  export { numPick } from './numPick.js';
4
9
  export { numUnique } from './numUnique.js';
10
+ export { round } from './round.js';
5
11
  export { sub } from './sub.js';
6
12
  export { sum } from './sum.js';
@@ -1 +1 @@
1
- export{div}from"./div.js";export{mul}from"./mul.js";export{numPick}from"./numPick.js";export{numUnique}from"./numUnique.js";export{sub}from"./sub.js";export{sum}from"./sum.js";
1
+ export{ceil}from"./ceil.js";export{clamp}from"./clamp.js";export{div}from"./div.js";export{floor}from"./floor.js";export{max}from"./max.js";export{min}from"./min.js";export{mul}from"./mul.js";export{numPick}from"./numPick.js";export{numUnique}from"./numUnique.js";export{round}from"./round.js";export{sub}from"./sub.js";export{sum}from"./sum.js";
@@ -0,0 +1,2 @@
1
+ export declare function max(...args: any[]): number | null;
2
+ export declare function max(...args: Array<number>): number | null;
@@ -0,0 +1 @@
1
+ export function max(...n){const r=n.length>0&&Array.isArray(n[0])?n[0]:n;let t=null;for(let n=0,e=r.length;n<e;n+=1){const e=r[n];"number"==typeof e&&!Number.isNaN(e)&&(null===t||e>t)&&(t=e)}return t}
@@ -0,0 +1,2 @@
1
+ export declare function min(...args: any[]): number | null;
2
+ export declare function min(...args: Array<number>): number | null;
@@ -0,0 +1 @@
1
+ export function min(...n){const r=n.length>0&&Array.isArray(n[0])?n[0]:n;let t=null;for(let n=0,e=r.length;n<e;n+=1){const e=r[n];"number"==typeof e&&!Number.isNaN(e)&&(null===t||e<t)&&(t=e)}return t}
@@ -0,0 +1 @@
1
+ export declare function round(value: number, precision?: number): number;
@@ -0,0 +1 @@
1
+ import{decimalShift as r}from"./_decimalShift.js";export function round(t,n=0){if(!Number.isFinite(t))return t;const i=r(t,n),o=i<0?-Math.round(-i):Math.round(i);return r(o,-n)}
@@ -1,8 +1,12 @@
1
+ export { objClone } from './objClone.js';
1
2
  export { objDeleteKeyByValue } from './objDeleteKeyByValue.js';
2
3
  export { objFindItemRecursiveByKey } from './objFindItemRecursiveByKey.js';
4
+ export { objGet } from './objGet.js';
3
5
  export { objInvert } from './objInvert.js';
4
6
  export { objMapKeys } from './objMapKeys.js';
7
+ export { objMerge } from './objMerge.js';
5
8
  export { objMergeNewKey } from './objMergeNewKey.js';
9
+ export { objPick } from './objPick.js';
6
10
  export { objPickBy } from './objPickBy.js';
7
11
  export { objTo1d } from './objTo1d.js';
8
12
  export { objToArray } from './objToArray.js';
@@ -1 +1 @@
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";
1
+ export{objClone}from"./objClone.js";export{objDeleteKeyByValue}from"./objDeleteKeyByValue.js";export{objFindItemRecursiveByKey}from"./objFindItemRecursiveByKey.js";export{objGet}from"./objGet.js";export{objInvert}from"./objInvert.js";export{objMapKeys}from"./objMapKeys.js";export{objMerge}from"./objMerge.js";export{objMergeNewKey}from"./objMergeNewKey.js";export{objPick}from"./objPick.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,3 @@
1
+ export declare function objClone(obj: any, options?: {
2
+ deep?: boolean;
3
+ }): any;
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../verify/isObject.js";function t(n,r){if(null===n||"object"!=typeof n)return n;if(r.has(n))return r.get(n);if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(Array.isArray(n)){const e=[];r.set(n,e);for(let a=0,o=n.length;a<o;a+=1)e[a]=t(n[a],r);return e}if(n instanceof Map){const e=new Map;return r.set(n,e),n.forEach((n,a)=>{e.set(t(a,r),t(n,r))}),e}if(n instanceof Set){const e=new Set;return r.set(n,e),n.forEach(n=>{e.add(t(n,r))}),e}if(e(n)){const e={};return r.set(n,e),Object.keys(n).forEach(a=>{e[a]=t(n[a],r)}),e}return n}export function objClone(n,r){return null===n||"object"!=typeof n?n:!1===r?.deep?Array.isArray(n)?[...n]:n instanceof Date?new Date(n.getTime()):n instanceof RegExp?new RegExp(n.source,n.flags):n instanceof Map?new Map(n):n instanceof Set?new Set(n):e(n)?{...n}:n:t(n,new WeakMap)}
@@ -0,0 +1,4 @@
1
+ import type { AnyValueObject } from '../_types/global';
2
+ export declare function objGet(obj: AnyValueObject, path: string, options?: {
3
+ fallback?: any;
4
+ }): any;
@@ -0,0 +1 @@
1
+ export function objGet(t,n,e){const o=e?.fallback??null;if(!t||"object"!=typeof t||"string"!=typeof n)return o;const c=function(t){const n=[],e=t.length;let o="",c=0;for(;c<e;){const e=t[c];if("["===e){const l=t.indexOf("]",c);if(-1===l){o+=e,c+=1;continue}""!==o&&(n.push(o),o="");let s=t.slice(c+1,l);const u=s[0];s.length>=2&&("'"===u||'"'===u)&&s.endsWith(u)&&(s=s.slice(1,-1)),n.push(s),c=l+1,"."===t[c]&&(c+=1);continue}"."!==e?(o+=e,c+=1):(n.push(o),o="",c+=1)}return""===o&&0!==n.length||n.push(o),n}(n);let l=t;for(let t=0,n=c.length;t<n;t+=1){if(null===l||"object"!=typeof l||!Object.hasOwn(l,c[t]))return o;l=l[c[t]]}return l}
@@ -0,0 +1,2 @@
1
+ import type { AnyValueObject } from '../_types/global';
2
+ export declare function objMerge(...objects: AnyValueObject[]): AnyValueObject | null;
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../verify/isObject.js";export function objMerge(...t){if(0===t.length)return null;const n={};for(let r=0,o=t.length;r<o;r+=1){const o=t[r];if(!e(o))return null;const l=Object.keys(o);for(let t=0,r=l.length;t<r;t+=1){const r=l[t],c=o[r];n[r]=e(n[r])&&e(c)?objMerge(n[r],c):c}}return n}
@@ -0,0 +1,2 @@
1
+ import type { AnyValueObject } from '../_types/global';
2
+ export declare function objPick(obj: AnyValueObject, keys: string | string[]): AnyValueObject | null;
@@ -0,0 +1 @@
1
+ export function objPick(t,r){if(!t||"object"!=typeof t)return null;const n=Array.isArray(r)?r:[r],e={};for(let r=0,o=n.length;r<o;r+=1){const o=n[r];Object.hasOwn(t,o)&&(e[o]=t[o])}return e}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * (Private, not exported from the package) Uppercases the first character of a word and
3
+ * lowercases the rest, so `XML` becomes `Xml`.
4
+ *
5
+ * The word is split by code point rather than indexed, because indexing a JavaScript string
6
+ * walks UTF-16 units and would cut a surrogate pair in half, disagreeing with the Dart and
7
+ * Python implementations. This is what the case-conversion family needs, and it is not the
8
+ * same as the public `capitalizeFirst`, which leaves the rest of the string alone.
9
+ */
10
+ export declare function capitalizeWord(word: string): string;
@@ -0,0 +1 @@
1
+ export function capitalizeWord(r){if(!r)return"";const e=Array.from(r);return e[0].toUpperCase()+e.slice(1).join("").toLowerCase()}
@@ -5,6 +5,7 @@ export { deburr } from './deburr.js';
5
5
  export { escapeRegExp } from './escapeRegExp.js';
6
6
  export { getGroupKeys } from './getGroupKeys.js';
7
7
  export { getStrBytes } from './getStrBytes.js';
8
+ export { pad } from './pad.js';
8
9
  export { removeNewLine } from './removeNewLine.js';
9
10
  export { removeSpecialChar } from './removeSpecialChar.js';
10
11
  export { replaceBetween } from './replaceBetween.js';
@@ -14,6 +15,11 @@ export { strCount } from './strCount.js';
14
15
  export { strRandom } from './strRandom.js';
15
16
  export { strShuffle } from './strShuffle.js';
16
17
  export { strToAscii } from './strToAscii.js';
18
+ export { strToCamelCase } from './strToCamelCase.js';
19
+ export { strToConstantCase } from './strToConstantCase.js';
20
+ export { strToKebabCase } from './strToKebabCase.js';
21
+ export { strToPascalCase } from './strToPascalCase.js';
22
+ export { strToSnakeCase } from './strToSnakeCase.js';
17
23
  export { strUnique } from './strUnique.js';
18
24
  export { trim } from './trim.js';
19
25
  export { truncate } from './truncate.js';
@@ -1 +1 @@
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";
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{pad}from"./pad.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{strToCamelCase}from"./strToCamelCase.js";export{strToConstantCase}from"./strToConstantCase.js";export{strToKebabCase}from"./strToKebabCase.js";export{strToPascalCase}from"./strToPascalCase.js";export{strToSnakeCase}from"./strToSnakeCase.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,2 @@
1
+ import type { PadOptions } from '../_types/global';
2
+ export declare function pad(str: string, length: number, options?: PadOptions): string;
@@ -0,0 +1 @@
1
+ function t(t,r){if(r<=0)return"";const n=Array.from(t);let o="";for(let t=0;t<r;t+=1)o+=n[t%n.length];return o}export function pad(r,n,o){const e=r||"",f=o?.char??" ",a=Array.from(e).length;if(a>=n||!f)return e;const c=n-a,i=o?.position??"both";let l=Math.floor(c/2);return"start"===i?l=c:"end"===i&&(l=0),t(f,l)+e+t(f,c-l)}
@@ -0,0 +1 @@
1
+ export declare function strToCamelCase(str: string): string;
@@ -0,0 +1 @@
1
+ import{capitalizeWord as o}from"./_capitalizeWord.js";import{words as r}from"./words.js";export function strToCamelCase(t){return t?r(t).map((r,t)=>0===t?r.toLowerCase():o(r)).join(""):""}
@@ -0,0 +1 @@
1
+ export declare function strToConstantCase(str: string): string;
@@ -0,0 +1 @@
1
+ import{words as o}from"./words.js";export function strToConstantCase(r){return r?o(r).map(o=>o.toUpperCase()).join("_"):""}
@@ -0,0 +1 @@
1
+ export declare function strToKebabCase(str: string): string;
@@ -0,0 +1 @@
1
+ import{words as o}from"./words.js";export function strToKebabCase(r){return r?o(r).map(o=>o.toLowerCase()).join("-"):""}
@@ -0,0 +1 @@
1
+ export declare function strToPascalCase(str: string): string;
@@ -0,0 +1 @@
1
+ import{capitalizeWord as o}from"./_capitalizeWord.js";import{words as r}from"./words.js";export function strToPascalCase(t){return t?r(t).map(o).join(""):""}
@@ -0,0 +1 @@
1
+ export declare function strToSnakeCase(str: string): string;
@@ -0,0 +1 @@
1
+ import{words as o}from"./words.js";export function strToSnakeCase(r){return r?o(r).map(o=>o.toLowerCase()).join("_"):""}
@@ -0,0 +1 @@
1
+ export declare function escapeHtml(str: string): string;
@@ -0,0 +1 @@
1
+ const t=/[&<>"']/g,e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};export function escapeHtml(c){return c?c.replace(t,t=>e[t]):""}
@@ -1,3 +1,4 @@
1
+ export { escapeHtml } from './escapeHtml.js';
1
2
  export { generateLicense } from './generateLicense.js';
2
3
  export { getParsedInfoFromAddress } from './getParsedInfoFromAddress.js';
3
4
  export { getSlug } from './getSlug.js';
@@ -5,3 +6,4 @@ export { isBotAgent } from './isBotAgent.js';
5
6
  export { isMatchPathname } from './isMatchPathname.js';
6
7
  export { isMobile } from './isMobile.js';
7
8
  export { removeLocalePrefix } from './removeLocalePrefix.js';
9
+ export { unescapeHtml } from './unescapeHtml.js';
package/dist/web/index.js CHANGED
@@ -1 +1 @@
1
- export{generateLicense}from"./generateLicense.js";export{getParsedInfoFromAddress}from"./getParsedInfoFromAddress.js";export{getSlug}from"./getSlug.js";export{isBotAgent}from"./isBotAgent.js";export{isMatchPathname}from"./isMatchPathname.js";export{isMobile}from"./isMobile.js";export{removeLocalePrefix}from"./removeLocalePrefix.js";
1
+ export{escapeHtml}from"./escapeHtml.js";export{generateLicense}from"./generateLicense.js";export{getParsedInfoFromAddress}from"./getParsedInfoFromAddress.js";export{getSlug}from"./getSlug.js";export{isBotAgent}from"./isBotAgent.js";export{isMatchPathname}from"./isMatchPathname.js";export{isMobile}from"./isMobile.js";export{removeLocalePrefix}from"./removeLocalePrefix.js";export{unescapeHtml}from"./unescapeHtml.js";
@@ -0,0 +1 @@
1
+ export declare function unescapeHtml(str: string): string;
@@ -0,0 +1 @@
1
+ const t=/&(?:amp|lt|gt|quot|#39);/g,e={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"};export function unescapeHtml(n){return n?n.replace(t,t=>e[t]):""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.16.0",
3
+ "version": "1.17.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",
@@ -83,7 +83,7 @@
83
83
  "jiti": "^2.7.0",
84
84
  "prettier": "^3.9.6",
85
85
  "terser-glob": "^1.2.1",
86
- "tsx": "^4.23.5",
86
+ "tsx": "^4.23.9",
87
87
  "typescript": "6.0.3",
88
88
  "typescript-eslint": "^8.66.0"
89
89
  }