@tempots/std 0.19.0 → 0.21.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.
package/string.d.ts CHANGED
@@ -4,15 +4,6 @@
4
4
  * Use by importing the desired utility from "@tempots/std" or directly from "@tempots/std/string".
5
5
  * @public
6
6
  */
7
- /**
8
- * Replaces all occurrances of `placeholder` in `subject` with the value `replacement`.
9
- * @param subject - The string to search in.
10
- * @param placeholder - The string to search for.
11
- * @param replacement - The string to replace `placeholder` with.
12
- * @returns The string with all occurrances of `placeholder` replaced by `replacement`.
13
- * @public
14
- */
15
- export declare const replaceAll: (subject: string, placeholder: string, replacement: string) => string;
16
7
  /**
17
8
  * `substringAfter` searches for the first occurrance of `searchFor` and returns the text after that.
18
9
  * If `searchFor` is not found, an empty string is returned.
@@ -87,16 +78,7 @@ export declare const canonicalizeNewlines: (value: string) => string;
87
78
  * @returns A negative number if `a` is less than `b`, zero if they are equal, or a positive number if `a` is greater than `b`.
88
79
  * @public
89
80
  */
90
- export declare const compareCaseInsensitive: (a: string, b: string) => number;
91
- /**
92
- * Checks if a string ends with a specified suffix.
93
- *
94
- * @param s - The string to check.
95
- * @param end - The suffix to check against.
96
- * @returns `true` if the string ends with the specified suffix, `false` otherwise.
97
- * @public
98
- */
99
- export declare const stringEndsWith: (s: string, end: string) => boolean;
81
+ export declare const compareCaseInsensitive: (a: string | null | undefined, b: string | null | undefined) => number;
100
82
  /**
101
83
  * Checks if a string ends with another string in a case-insensitive manner.
102
84
  *
@@ -106,15 +88,6 @@ export declare const stringEndsWith: (s: string, end: string) => boolean;
106
88
  * @public
107
89
  */
108
90
  export declare const textEndsWithCaseInsensitive: (s: string, end: string) => boolean;
109
- /**
110
- * Checks if a string starts with a specified substring.
111
- *
112
- * @param s - The string to check.
113
- * @param start - The substring to check for at the beginning of the string.
114
- * @returns `true` if the string starts with the specified substring, `false` otherwise.
115
- * @public
116
- */
117
- export declare const stringStartsWith: (s: string, start: string) => boolean;
118
91
  /**
119
92
  * Checks if a string starts with another string in a case-insensitive manner.
120
93
  *
@@ -172,15 +145,6 @@ export declare const compareStrings: (a: string, b: string) => number;
172
145
  * @public
173
146
  */
174
147
  export declare const textContainsCaseInsensitive: (s: string, test: string) => boolean;
175
- /**
176
- * `textContains` returns `true` if `s` contains one or more occurrences of `test`.
177
- *
178
- * @param s - The string to search in.
179
- * @param test - The string to search for.
180
- * @returns `true` if `s` contains `test`, `false` otherwise.
181
- * @public
182
- */
183
- export declare const stringContains: (s: string, test: string) => boolean;
184
148
  /**
185
149
  * Return the number of occurrences of `test` in `s`.
186
150
  *
@@ -417,7 +381,7 @@ export declare const lowerCaseFirst: (value: string) => string;
417
381
  * @returns The random substring.
418
382
  * @public
419
383
  */
420
- export declare const randomString: (value: string, length?: number) => string;
384
+ export declare const randomSubString: (value: string, length?: number) => string;
421
385
  /**
422
386
  * Returns a random sampling of the specified length from the seed string.
423
387
  *
@@ -490,20 +454,6 @@ export declare const deleteStringBefore: (value: string, toremove: string) => st
490
454
  * @public
491
455
  */
492
456
  export declare const deleteFirstFromString: (value: string, toremove: string) => string;
493
- /**
494
- * `repeatString` builds a new string by repeating the argument `s`, n `times`.
495
- *
496
- * @example
497
- * ```ts
498
- * repeatString('Xy', 3) // generates 'XyXyXy'
499
- * ```
500
- *
501
- * @param s - The string to repeat.
502
- * @param times - The number of times to repeat the string.
503
- * @returns The repeated string.
504
- * @public
505
- */
506
- export declare const repeatString: (s: string, times: number) => string;
507
457
  /**
508
458
  * Returns a new string whose characters are in reverse order.
509
459
  *
@@ -570,14 +520,6 @@ export declare const stringStartsWithAny: (s: string, values: string[]) => boole
570
520
  * @public
571
521
  */
572
522
  export declare const surroundString: (s: string, left: string, right?: string) => string;
573
- /**
574
- * It transforms a string into an `Array` of characters.
575
- *
576
- * @param s - The string to transform.
577
- * @returns An array of characters.
578
- * @public
579
- */
580
- export declare const stringToChars: (s: string) => string[];
581
523
  /**
582
524
  * It transforms a string into an `Array` of char codes in integer format.
583
525
  *
package/string.js CHANGED
@@ -1,206 +1,199 @@
1
- import { anyElement as l, allElements as b, generateArray as S, createFilledArray as O } from "./array.js";
2
- import { MissingImplementationError as A } from "./error.js";
3
- import { mapRegExp as h } from "./regexp.js";
4
- const u = (t, n, e) => t.split(n).join(e), X = (t, n) => {
1
+ import { MissingImplementationError as p } from "./error.js";
2
+ import { mapRegExp as l } from "./regexp.js";
3
+ const Z = (t, n) => {
5
4
  const e = t.indexOf(n);
6
5
  return e < 0 ? "" : t.substring(e + n.length);
7
- }, Y = (t, n) => {
6
+ }, D = (t, n) => {
8
7
  const e = t.lastIndexOf(n);
9
8
  return e < 0 ? "" : t.substring(e + n.length);
10
- }, v = (t, n) => {
9
+ }, P = (t, n) => {
11
10
  const e = t.indexOf(n);
12
11
  return e < 0 ? "" : t.substring(0, e);
13
- }, tt = (t, n) => {
12
+ }, R = (t, n) => {
14
13
  const e = t.lastIndexOf(n);
15
14
  return e < 0 ? "" : t.substring(0, e);
16
- }, p = (t) => t.substring(0, 1).toUpperCase() + t.substring(1), d = (t) => t.toUpperCase(), nt = (t, n = !1) => n ? h(p(t), F, d) : h(p(t), D, d), et = (t) => t.replace(K, `
17
- `), rt = (t, n) => t == null && n == null ? 0 : t == null ? -1 : n == null ? 1 : W(t.toLowerCase(), n.toLowerCase()), L = (t, n) => t.substring(0, t.length - n.length) === n, st = (t, n) => t.substring(0, t.length - n.length).toLowerCase() === n.toLowerCase(), x = (t, n) => t.substring(0, n.length) === n, it = (t, n) => t.substring(0, n.length).toLowerCase() === n.toLowerCase(), ot = (t, n) => B(
15
+ }, g = (t) => t.substring(0, 1).toUpperCase() + t.substring(1), f = (t) => t.toUpperCase(), F = (t, n = !1) => n ? l(g(t), _, f) : l(g(t), z, f), G = (t) => t.replace($, `
16
+ `), Q = (t, n) => t == null && n == null ? 0 : t == null ? -1 : n == null ? 1 : b(t.toLowerCase(), n.toLowerCase()), K = (t, n) => t.substring(t.length - n.length).toLowerCase() === n.toLowerCase(), q = (t, n) => t.substring(0, n.length).toLowerCase() === n.toLowerCase(), J = (t, n) => S(
18
17
  t.toLowerCase(),
19
18
  n.map((e) => e.toLowerCase())
20
- ), ct = (t, n) => M(
19
+ ), V = (t, n) => y(
21
20
  t.toLowerCase(),
22
21
  n.map((e) => e.toLowerCase())
23
- ), ut = (t) => t.trim().replace(m, " "), W = (t, n) => t < n ? -1 : t > n ? 1 : 0, w = (t, n) => t.toLowerCase().includes(n.toLowerCase()), a = (t, n) => t.includes(n), gt = (t, n) => t.split(n).length - 1, lt = (t, n) => l(n, (e) => w(t, e)), at = (t, n) => l(n, (e) => a(t, e)), ft = (t, n) => b(n, (e) => w(t, e)), ht = (t, n) => b(n, (e) => a(t, e)), pt = (t) => t.replace("_", "-"), dt = (t, n) => {
22
+ ), X = (t) => t.trim().replace(d, " "), b = (t, n) => t < n ? -1 : t > n ? 1 : 0, h = (t, n) => t.toLowerCase().includes(n.toLowerCase()), Y = (t, n) => t.split(n).length - 1, v = (t, n) => n.some((e) => h(t, e)), tt = (t, n) => n.some((e) => t.includes(e)), nt = (t, n) => n.every((e) => h(t, e)), et = (t, n) => n.every((e) => t.includes(e)), rt = (t) => t.replace(/_/g, "-"), st = (t, n) => {
24
23
  if (t === n) return -1;
25
24
  const e = Math.min(t.length, n.length);
26
25
  for (let r = 0; r < e; r++)
27
26
  if (t.substring(r, r + 1) !== n.substring(r, r + 1)) return r;
28
27
  return e;
29
- }, y = (t, n = 20, e = "…") => {
28
+ }, A = (t, n = 20, e = "…") => {
30
29
  const r = t.length, s = e.length;
31
30
  return r > n ? n < s ? e.slice(s - n, n) : t.slice(0, n - s) + e : t;
32
- }, Ct = (t, n = 20, e = "…") => {
31
+ }, it = (t, n = 20, e = "…") => {
33
32
  const r = t.length, s = e.length;
34
33
  if (r > n) {
35
34
  if (n <= s)
36
- return y(t, n, e);
37
- const c = Math.ceil((n - s) / 2), g = Math.floor((n - s) / 2);
38
- return t.slice(0, c) + e + t.slice(r - g);
35
+ return A(t, n, e);
36
+ const c = Math.ceil((n - s) / 2), u = Math.floor((n - s) / 2);
37
+ return t.slice(0, c) + e + t.slice(r - u);
39
38
  } else return t;
40
- }, B = (t, n) => l(n, (e) => L(t, e)), bt = (t, n) => f(t).filter(n).join(""), St = (t, n) => _(t).filter(n).map((r) => String.fromCharCode(r)).join(""), At = (t, n = 2166136261) => {
39
+ }, S = (t, n) => n.some((e) => t.endsWith(e)), ot = (t, n) => Array.from(t).filter(n).join(""), ct = (t, n) => x(t).filter(n).map((r) => String.fromCharCode(r)).join(""), ut = (t, n = 2166136261) => {
41
40
  let e = n;
42
41
  for (let r = 0, s = t.length; r < s; r++)
43
42
  e ^= t.charCodeAt(r), e += (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
44
43
  return e >>> 0;
45
- }, Lt = (t) => t != null && t.length > 0, wt = (t) => u(k(t), "_", " "), It = (t) => t.length > 0 && !R.test(t), mt = (t) => G.test(t), Et = (t) => !P.test(t), Ot = (t) => t.toLowerCase() === t, xt = (t) => t.toUpperCase() === t, Wt = (t, n) => t != null && t !== "" ? t : n, yt = (t) => Q.test(t), Bt = (t) => t == null || t === "", zt = (t) => t.substring(0, 1).toLowerCase() + t.substring(1), z = (t, n = 1) => t.substring(
46
- Math.floor((t.length - n + 1) * Math.random()),
47
- n
48
- ), T = (t, n) => S(n, () => z(t)).join(""), Tt = (t) => T(Z, t), jt = (t, n) => f(n).map(t), Nt = (t, n) => u(t, n, ""), Mt = (t, n) => L(t, n) ? t.substring(0, t.length - n.length) : t, _t = (t, n, e) => t.substring(0, n) + t.substring(n + e), Ut = (t, n) => x(t, n) ? t.substring(n.length) : t, $t = (t, n) => {
44
+ }, lt = (t) => t != null && t.length > 0, gt = (t) => E(t).split("_").join(" "), ft = (t) => t.length > 0 && !N.test(t), at = (t) => M.test(t), pt = (t) => !T.test(t), ht = (t) => t.toLowerCase() === t, dt = (t) => t.toUpperCase() === t, Ct = (t, n) => t != null && t !== "" ? t : n, bt = (t) => U.test(t), At = (t) => t == null || t === "", St = (t) => t.substring(0, 1).toLowerCase() + t.substring(1), L = (t, n = 1) => {
45
+ const e = Math.floor((t.length - n + 1) * Math.random());
46
+ return t.substring(e, e + n);
47
+ }, m = (t, n) => Array.from({ length: n }, () => L(t)).join(""), Lt = (t) => m(j, t), mt = (t, n) => Array.from(n).map(t), wt = (t, n) => t.split(n).join(""), It = (t, n) => t.endsWith(n) ? t.substring(0, t.length - n.length) : t, yt = (t, n, e) => t.substring(0, n) + t.substring(n + e), xt = (t, n) => t.startsWith(n) ? t.substring(n.length) : t, Ot = (t, n) => {
49
48
  const e = t.indexOf(n);
50
49
  return e < 0 ? t : t.substring(0, e) + t.substring(e + n.length);
51
- }, I = (t, n) => O(n, t).join(""), kt = (t) => {
52
- const n = f(t);
50
+ }, Wt = (t) => {
51
+ const n = Array.from(t);
53
52
  return n.reverse(), n.join("");
54
- }, j = (t, n = "'") => n === "'" ? t.includes("'") ? t.includes('"') ? "'" + u(t, "'", "\\'") + "'" : '"' + t + '"' : "'" + t + "'" : t.includes('"') ? t.includes("'") ? '"' + u(t, '"', '\\"') + '"' : "'" + t + "'" : '"' + t + '"', N = (t, n = "'") => n + u(t, n, "\\" + n) + n, Ht = (t, n = "'") => t.indexOf(`
55
- `) >= 0 ? N(t, "`") : j(t, n), Zt = (t, n) => {
53
+ }, w = (t, n = "'") => n === "'" ? t.includes("'") ? t.includes('"') ? "'" + t.split("'").join("\\'") + "'" : '"' + t + '"' : "'" + t + "'" : t.includes('"') ? t.includes("'") ? '"' + t.split('"').join('\\"') + '"' : "'" + t + "'" : '"' + t + '"', I = (t, n = "'") => n + t.split(n).join("\\" + n) + n, Et = (t, n = "'") => t.indexOf(`
54
+ `) >= 0 ? I(t, "`") : w(t, n), Bt = (t, n) => {
56
55
  const e = t.indexOf(n);
57
56
  return e < 0 ? [t] : [t.substring(0, e), t.substring(e + n.length)];
58
- }, M = (t, n) => l(n, (e) => t.startsWith(e)), Dt = (t, n, e = n) => `${n}${t}${e}`, f = (t) => t.split(""), _ = (t) => S(t.length, (n) => t.charCodeAt(n)), Pt = (t, n) => {
57
+ }, y = (t, n) => n.some((e) => t.startsWith(e)), jt = (t, n, e = n) => `${n}${t}${e}`, x = (t) => Array.from({ length: t.length }, (n, e) => t.charCodeAt(e)), zt = (t, n) => {
59
58
  const e = [];
60
59
  for (; t.length > 0; )
61
60
  e.push(t.substring(0, n)), t = t.substring(n, t.length - n);
62
61
  return e;
63
- }, Rt = (t) => t.split(E), Ft = (t, n) => $(U(t, n), n), U = (t, n) => {
62
+ }, Tt = (t) => t.split(C), Nt = (t, n) => W(O(t, n), n), O = (t, n) => {
64
63
  let e = 0;
65
- for (let r = 0; r < t.length && a(n, t.charAt(r)); r++)
64
+ for (let r = 0; r < t.length && n.includes(t.charAt(r)); r++)
66
65
  e++;
67
66
  return t.substring(e);
68
- }, $ = (t, n) => {
67
+ }, W = (t, n) => {
69
68
  const e = t.length;
70
69
  let r = e, s;
71
- for (let c = 0; c < e && (s = e - c - 1, a(n, t.charAt(s))); c++)
70
+ for (let c = 0; c < e && (s = e - c - 1, n.includes(t.charAt(s))); c++)
72
71
  r = s;
73
72
  return t.substring(0, r);
74
- }, k = (t) => (t = t.replace(/::/g, "/"), t = t.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2"), t = t.replace(/([a-z\d])([A-Z])/g, "$1_$2"), t = t.replace(/-/g, "_"), t.toLowerCase()), Gt = (t) => t.substring(0, 1).toUpperCase() + t.substring(1), Qt = (t, n = 78, e = "", r = `
75
- `) => t.split(E).map(
76
- (s) => H(s.replace(m, " ").trim(), n, e, r)
77
- ).join(r), C = (t, n) => {
73
+ }, E = (t) => (t = t.replace(/::/g, "/"), t = t.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2"), t = t.replace(/([a-z\d])([A-Z])/g, "$1_$2"), t = t.replace(/-/g, "_"), t.toLowerCase()), _t = (t) => t.substring(0, 1).toUpperCase() + t.substring(1), Mt = (t, n = 78, e = "", r = `
74
+ `) => t.split(C).map(
75
+ (s) => B(s.replace(d, " ").trim(), n, e, r)
76
+ ).join(r), a = (t, n) => {
78
77
  if (n < 0 || n >= t.length) return !1;
79
78
  const e = t.charCodeAt(n);
80
79
  return e === 9 || e === 10 || e === 11 || e === 12 || e === 13 || e === 32;
81
- }, Kt = (t) => {
80
+ }, Ut = (t) => {
82
81
  if (typeof Buffer < "u")
83
82
  return Buffer.from(t).toString("base64");
84
83
  if (typeof btoa < "u")
85
84
  return btoa(t);
86
- throw new A(
85
+ throw new p(
87
86
  "No implementation found for base64 encoding"
88
87
  );
89
- }, qt = (t) => {
88
+ }, $t = (t) => {
90
89
  if (typeof Buffer < "u")
91
90
  return Buffer.from(t, "base64").toString("utf8");
92
91
  if (typeof atob < "u")
93
92
  return atob(t);
94
- throw new A(
93
+ throw new p(
95
94
  "No implementation found for base64 decoding"
96
95
  );
97
- }, H = (t, n, e, r) => {
98
- const s = [], c = t.length, g = e.length;
96
+ }, B = (t, n, e, r) => {
97
+ const s = [], c = t.length, u = e.length;
99
98
  let o = 0;
100
- for (n -= g; ; ) {
101
- if (o + n >= c - g) {
99
+ for (n -= u; ; ) {
100
+ if (o + n >= c - u) {
102
101
  s.push(t.substring(o));
103
102
  break;
104
103
  }
105
104
  let i = 0;
106
- for (; !C(t, o + n - i) && i < n; ) i++;
105
+ for (; !a(t, o + n - i) && i < n; ) i++;
107
106
  if (i === n) {
108
- for (i = 0; !C(t, o + n + i) && o + n + i < c; ) i++;
107
+ for (i = 0; !a(t, o + n + i) && o + n + i < c; ) i++;
109
108
  s.push(t.substring(o, o + n + i)), o += n + i + 1;
110
109
  } else
111
110
  s.push(t.substring(o, o + n - i)), o += n - i + 1;
112
111
  }
113
112
  return e + s.join(r + e);
114
- }, Jt = (t, n, e) => {
113
+ }, kt = (t, n, e) => {
115
114
  const r = e - t.length;
116
- return r > 0 ? I(n, r) + t : t;
117
- }, Vt = (t, n, e) => {
115
+ return r > 0 ? n.repeat(r) + t : t;
116
+ }, Ht = (t, n, e) => {
118
117
  const r = e - t.length;
119
- return r > 0 ? t + I(n, r) : t;
120
- }, Xt = (t, n) => {
118
+ return r > 0 ? t + n.repeat(r) : t;
119
+ }, Zt = (t, n) => {
121
120
  const e = t.lastIndexOf(n);
122
121
  return e >= 0 ? [t.substring(0, e), t.substring(e + n.length)] : [t];
123
- }, Yt = (t, n) => {
122
+ }, Dt = (t, n) => {
124
123
  const e = t.indexOf(n);
125
124
  return e >= 0 ? [t.substring(0, e), t.substring(e + n.length)] : [t];
126
- }, Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", D = /[^a-zA-Z]([a-z])/g, P = /[^\t\n\r ]/, R = /[^a-zA-Z]/, F = /[ \t\r\n][a-z]/g, G = /^[a-z0-9]+$/i, Q = /^[0-9]+$/, m = /[ \t\r\n]+/g, E = /\r\n|\n\r|\n|\r/g, K = /\r\n|\n\r|\r/g;
125
+ }, j = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", z = /[^a-zA-Z]([a-z])/g, T = /[^\t\n\r ]/, N = /[^a-zA-Z]/, _ = /[ \t\r\n][a-z]/g, M = /^[a-z0-9]+$/i, U = /^[0-9]+$/, d = /[ \t\r\n]+/g, C = /\r\n|\n\r|\n|\r/g, $ = /\r\n|\n\r|\r/g;
127
126
  export {
128
- et as canonicalizeNewlines,
129
- p as capitalize,
130
- nt as capitalizeWords,
131
- Pt as chunkString,
132
- ut as collapseText,
133
- rt as compareCaseInsensitive,
134
- W as compareStrings,
135
- ht as containsAllText,
136
- ft as containsAllTextCaseInsensitive,
137
- at as containsAnyText,
138
- lt as containsAnyTextCaseInsensitive,
139
- gt as countStringOccurrences,
140
- pt as dasherize,
141
- qt as decodeBase64,
142
- $t as deleteFirstFromString,
143
- Mt as deleteStringAfter,
144
- Ut as deleteStringBefore,
145
- Nt as deleteSubstring,
146
- y as ellipsis,
147
- Ct as ellipsisMiddle,
148
- Kt as encodeBase64,
149
- St as filterCharcodes,
150
- bt as filterChars,
151
- wt as humanize,
152
- Wt as ifEmptyString,
153
- It as isAlpha,
154
- mt as isAlphaNum,
155
- Et as isBreakingWhitespace,
156
- yt as isDigitsOnly,
157
- Bt as isEmptyString,
158
- Ot as isLowerCase,
159
- C as isSpaceAt,
160
- xt as isUpperCase,
161
- Ht as jsQuote,
162
- zt as lowerCaseFirst,
163
- Jt as lpad,
164
- jt as mapChars,
165
- N as quote,
166
- z as randomString,
167
- T as randomStringSequence,
168
- Tt as randomStringSequenceBase64,
169
- I as repeatString,
170
- u as replaceAll,
171
- kt as reverseString,
172
- Vt as rpad,
173
- j as smartQuote,
174
- Yt as splitStringOnFirst,
175
- Xt as splitStringOnLast,
176
- Zt as splitStringOnce,
177
- a as stringContains,
178
- L as stringEndsWith,
179
- B as stringEndsWithAny,
180
- Lt as stringHasContent,
181
- At as stringHashCode,
182
- x as stringStartsWith,
183
- M as stringStartsWithAny,
184
- _ as stringToCharcodes,
185
- f as stringToChars,
186
- dt as stringsDifferAtIndex,
187
- X as substringAfter,
188
- Y as substringAfterLast,
189
- v as substringBefore,
190
- tt as substringBeforeLast,
191
- Dt as surroundString,
192
- w as textContainsCaseInsensitive,
193
- ot as textEndsWithAnyCaseInsensitive,
194
- st as textEndsWithCaseInsensitive,
195
- ct as textStartsWithAnyCaseInsensitive,
196
- it as textStartsWithCaseInsensitive,
197
- Rt as textToLines,
198
- Ft as trimChars,
199
- U as trimCharsLeft,
200
- $ as trimCharsRight,
201
- _t as trimStringSlice,
202
- k as underscore,
203
- Gt as upperCaseFirst,
204
- Qt as wrapColumns,
205
- H as wrapLine
127
+ G as canonicalizeNewlines,
128
+ g as capitalize,
129
+ F as capitalizeWords,
130
+ zt as chunkString,
131
+ X as collapseText,
132
+ Q as compareCaseInsensitive,
133
+ b as compareStrings,
134
+ et as containsAllText,
135
+ nt as containsAllTextCaseInsensitive,
136
+ tt as containsAnyText,
137
+ v as containsAnyTextCaseInsensitive,
138
+ Y as countStringOccurrences,
139
+ rt as dasherize,
140
+ $t as decodeBase64,
141
+ Ot as deleteFirstFromString,
142
+ It as deleteStringAfter,
143
+ xt as deleteStringBefore,
144
+ wt as deleteSubstring,
145
+ A as ellipsis,
146
+ it as ellipsisMiddle,
147
+ Ut as encodeBase64,
148
+ ct as filterCharcodes,
149
+ ot as filterChars,
150
+ gt as humanize,
151
+ Ct as ifEmptyString,
152
+ ft as isAlpha,
153
+ at as isAlphaNum,
154
+ pt as isBreakingWhitespace,
155
+ bt as isDigitsOnly,
156
+ At as isEmptyString,
157
+ ht as isLowerCase,
158
+ a as isSpaceAt,
159
+ dt as isUpperCase,
160
+ Et as jsQuote,
161
+ St as lowerCaseFirst,
162
+ kt as lpad,
163
+ mt as mapChars,
164
+ I as quote,
165
+ m as randomStringSequence,
166
+ Lt as randomStringSequenceBase64,
167
+ L as randomSubString,
168
+ Wt as reverseString,
169
+ Ht as rpad,
170
+ w as smartQuote,
171
+ Dt as splitStringOnFirst,
172
+ Zt as splitStringOnLast,
173
+ Bt as splitStringOnce,
174
+ S as stringEndsWithAny,
175
+ lt as stringHasContent,
176
+ ut as stringHashCode,
177
+ y as stringStartsWithAny,
178
+ x as stringToCharcodes,
179
+ st as stringsDifferAtIndex,
180
+ Z as substringAfter,
181
+ D as substringAfterLast,
182
+ P as substringBefore,
183
+ R as substringBeforeLast,
184
+ jt as surroundString,
185
+ h as textContainsCaseInsensitive,
186
+ J as textEndsWithAnyCaseInsensitive,
187
+ K as textEndsWithCaseInsensitive,
188
+ V as textStartsWithAnyCaseInsensitive,
189
+ q as textStartsWithCaseInsensitive,
190
+ Tt as textToLines,
191
+ Nt as trimChars,
192
+ O as trimCharsLeft,
193
+ W as trimCharsRight,
194
+ yt as trimStringSlice,
195
+ E as underscore,
196
+ _t as upperCaseFirst,
197
+ Mt as wrapColumns,
198
+ B as wrapLine
206
199
  };
package/timer.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=(e,t)=>{const n=setTimeout(e,t);return()=>clearTimeout(n)},w=(e,t)=>{const n=setInterval(e,t);return()=>clearInterval(n)},p=(e,t,n={})=>{const{noTrailing:s=!1,noLeading:u=!1,debounceMode:c}=n;let o,f=!1,i=0;function d(){o&&clearTimeout(o)}function b(a){const{upcomingOnly:r=!1}=a||{};d(),f=!r}function m(...a){if(f)return;const r=this,v=Date.now()-i;function l(){i=Date.now(),t.apply(r,a)}function T(){o=void 0}!u&&c&&!o&&l(),d(),c===void 0&&v>e?u?(i=Date.now(),s||(o=setTimeout(c?T:l,e))):l():s||(o=setTimeout(c?T:l,c===void 0?e-v:e))}return m.cancel=b,m},D=(e,t,{atBegin:n=!1}={})=>p(e,t,{debounceMode:n!==!1});exports.debounce=D;exports.delayed=g;exports.interval=w;exports.throttle=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=(n,e)=>{const t=setTimeout(n,e);return()=>clearTimeout(t)},b=(n,e)=>{const t=setInterval(n,e);return()=>clearInterval(t)},F=(n,e,t={})=>{const{noTrailing:o=!1,noLeading:l=!1,debounceMode:i}=t;let a,m=!1,c=0;function f(){a&&clearTimeout(a)}function T(u){const{upcomingOnly:s=!1}=u||{};f(),m=!s}function d(...u){if(m)return;const s=this,v=Date.now()-c;function r(){c=Date.now(),e.apply(s,u)}function A(){a=void 0}!l&&i&&!a&&r(),f(),i===void 0&&v>n?l?(c=Date.now(),o||(a=setTimeout(i?A:r,n))):r():o||(a=setTimeout(i?A:r,i===void 0?n-v:n))}return d.cancel=T,d},g=(n,e,{atBegin:t=!1}={})=>F(n,e,{debounceMode:t!==!1}),y=n=>{let e=null;const t=l=>{e=null,n(l)};return(()=>{e==null&&(e=requestAnimationFrame(t))})(),()=>{e!=null&&(cancelAnimationFrame(e),e=null)}},I=n=>{let e=null;const t=l=>{e=requestAnimationFrame(t),n(l)};return(()=>{e==null&&(e=requestAnimationFrame(t))})(),()=>{e!=null&&(cancelAnimationFrame(e),e=null)}};exports.debounce=g;exports.delayed=p;exports.delayedAnimationFrame=y;exports.interval=b;exports.intervalAnimationFrame=I;exports.throttle=F;
package/timer.d.ts CHANGED
@@ -163,3 +163,17 @@ export type DebounceOptions = {
163
163
  * @public
164
164
  */
165
165
  export declare const debounce: <FN extends (...args: unknown[]) => void>(delay: number, callback: FN, { atBegin }?: DebounceOptions) => ThrottledFunction<Parameters<FN>>;
166
+ /**
167
+ * Delays the execution of a function using requestAnimationFrame.
168
+ *
169
+ * @param callback - The function to delay.
170
+ * @returns A function that, when called, will cancel the delay and prevent the original function from being executed.
171
+ */
172
+ export declare const delayedAnimationFrame: (callback: (time: DOMHighResTimeStamp) => void) => () => void;
173
+ /**
174
+ * Executes a function repeatedly using requestAnimationFrame.
175
+ *
176
+ * @param callback - The function to execute periodically.
177
+ * @returns A function that, when called, will cancel the interval and stop future executions.
178
+ */
179
+ export declare const intervalAnimationFrame: (callback: (time: DOMHighResTimeStamp) => void) => () => void;
package/timer.js CHANGED
@@ -1,38 +1,60 @@
1
- const w = (e, t) => {
2
- const n = setTimeout(e, t);
3
- return () => clearTimeout(n);
4
- }, x = (e, t) => {
5
- const n = setInterval(e, t);
6
- return () => clearInterval(n);
7
- }, g = (e, t, n = {}) => {
8
- const { noTrailing: r = !1, noLeading: u = !1, debounceMode: c } = n;
9
- let o, f = !1, l = 0;
10
- function d() {
1
+ const T = (n, e) => {
2
+ const t = setTimeout(n, e);
3
+ return () => clearTimeout(t);
4
+ }, I = (n, e) => {
5
+ const t = setInterval(n, e);
6
+ return () => clearInterval(t);
7
+ }, F = (n, e, t = {}) => {
8
+ const { noTrailing: a = !1, noLeading: l = !1, debounceMode: i } = t;
9
+ let o, f = !1, c = 0;
10
+ function m() {
11
11
  o && clearTimeout(o);
12
12
  }
13
- function v(s) {
14
- const { upcomingOnly: a = !1 } = s || {};
15
- d(), f = !a;
13
+ function A(u) {
14
+ const { upcomingOnly: s = !1 } = u || {};
15
+ m(), f = !s;
16
16
  }
17
- function m(...s) {
17
+ function d(...u) {
18
18
  if (f) return;
19
- const a = this, p = Date.now() - l;
20
- function i() {
21
- l = Date.now(), t.apply(a, s);
19
+ const s = this, p = Date.now() - c;
20
+ function r() {
21
+ c = Date.now(), e.apply(s, u);
22
22
  }
23
- function T() {
23
+ function v() {
24
24
  o = void 0;
25
25
  }
26
- !u && c && !o && i(), d(), c === void 0 && p > e ? u ? (l = Date.now(), r || (o = setTimeout(c ? T : i, e))) : i() : r || (o = setTimeout(
27
- c ? T : i,
28
- c === void 0 ? e - p : e
26
+ !l && i && !o && r(), m(), i === void 0 && p > n ? l ? (c = Date.now(), a || (o = setTimeout(i ? v : r, n))) : r() : a || (o = setTimeout(
27
+ i ? v : r,
28
+ i === void 0 ? n - p : n
29
29
  ));
30
30
  }
31
- return m.cancel = v, m;
32
- }, D = (e, t, { atBegin: n = !1 } = {}) => g(e, t, { debounceMode: n !== !1 });
31
+ return d.cancel = A, d;
32
+ }, g = (n, e, { atBegin: t = !1 } = {}) => F(n, e, { debounceMode: t !== !1 }), w = (n) => {
33
+ let e = null;
34
+ const t = (l) => {
35
+ e = null, n(l);
36
+ };
37
+ return (() => {
38
+ e == null && (e = requestAnimationFrame(t));
39
+ })(), () => {
40
+ e != null && (cancelAnimationFrame(e), e = null);
41
+ };
42
+ }, x = (n) => {
43
+ let e = null;
44
+ const t = (l) => {
45
+ e = requestAnimationFrame(t), n(l);
46
+ };
47
+ return (() => {
48
+ e == null && (e = requestAnimationFrame(t));
49
+ })(), () => {
50
+ e != null && (cancelAnimationFrame(e), e = null);
51
+ };
52
+ };
33
53
  export {
34
- D as debounce,
35
- w as delayed,
36
- x as interval,
37
- g as throttle
54
+ g as debounce,
55
+ T as delayed,
56
+ w as delayedAnimationFrame,
57
+ I as interval,
58
+ x as intervalAnimationFrame,
59
+ F as throttle
38
60
  };
package/url.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=t=>{try{return new URL(t)}catch{return null}},u=(t,e)=>{if(!e||Object.keys(e).length===0)return t;const n=new URL(t);for(const[r,s]of Object.entries(e))n.searchParams.set(r,s);return n.toString()},g=t=>{try{const e=new URL(t),n={};for(const[r,s]of e.searchParams)n[r]=s;return n}catch{return{}}},h=(t,e,n)=>{try{const r=new URL(t);return r.searchParams.set(e,n),r.toString()}catch{return t}},f=(t,e)=>{try{const n=new URL(t);return n.searchParams.delete(e),n.toString()}catch{return t}},m=t=>{try{return new URL(t),!0}catch{return!1}},P=(...t)=>{if(t.length===0)return"";const e=t.filter(a=>a.length>0);if(e.length===0)return"";const n=e[0].startsWith("/"),r=e[e.length-1].endsWith("/"),o=e.map(a=>a.replace(/^\/+|\/+$/g,"")).filter(a=>a.length>0).join("/");return(n?"/":"")+o+(r?"/":"")},y=t=>{if(!t)return"";const e=t.startsWith("/"),n=t.split("/").filter(o=>o.length>0),r=[];for(const o of n)o!=="."&&(o===".."?r.length>0&&r[r.length-1]!==".."?r.pop():e||r.push(".."):r.push(o));const s=r.join("/");return e?"/"+s:s},c=t=>{const e=l(t),n=e.lastIndexOf(".");return n===-1||n===0?"":e.substring(n)},l=t=>{if(!t||t.match(/\/+$/))return"";const e=t.lastIndexOf("/");return e===-1?t:t.substring(e+1)},d=t=>{const e=l(t),n=c(t);return n?e.substring(0,e.length-n.length):e};exports.buildUrl=u;exports.getBaseName=d;exports.getFileExtension=c;exports.getFileName=l;exports.getQueryParams=g;exports.isValidUrl=m;exports.joinPaths=P;exports.normalizePath=y;exports.parseUrl=i;exports.removeQueryParam=f;exports.setQueryParam=h;