@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/random.d.ts ADDED
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Utilities for generating random values.
3
+ *
4
+ * This module provides enhanced random number generation, choice selection,
5
+ * and other randomization utilities that go beyond Math.random().
6
+ * All functions use Math.random() as the underlying source of randomness.
7
+ *
8
+ * @public
9
+ */
10
+ /**
11
+ * Generates a random integer between min and max (inclusive).
12
+ *
13
+ * This function provides a more convenient API than manually scaling Math.random()
14
+ * and handles the common case of generating integers within a specific range.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const dice = randomInt(1, 6) // 1, 2, 3, 4, 5, or 6
19
+ * const index = randomInt(0, array.length - 1) // Valid array index
20
+ * ```
21
+ *
22
+ * @param min - The minimum value (inclusive)
23
+ * @param max - The maximum value (inclusive)
24
+ * @returns A random integer between min and max
25
+ * @public
26
+ */
27
+ export declare const randomInt: (min: number, max: number) => number;
28
+ /**
29
+ * Generates a random floating-point number between min and max.
30
+ *
31
+ * This function provides a convenient way to generate random floats
32
+ * within a specific range, with optional exclusion of the maximum value.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const temperature = randomFloat(-10.0, 35.0) // Random temperature
37
+ * const percentage = randomFloat(0, 100) // Random percentage
38
+ * ```
39
+ *
40
+ * @param min - The minimum value (inclusive)
41
+ * @param max - The maximum value (exclusive by default)
42
+ * @param inclusive - Whether to include the maximum value (default: false)
43
+ * @returns A random float between min and max
44
+ * @public
45
+ */
46
+ export declare const randomFloat: (min: number, max: number, inclusive?: boolean) => number;
47
+ /**
48
+ * Selects a random element from an array.
49
+ *
50
+ * This function provides a convenient way to pick a random item
51
+ * from an array, handling the index calculation automatically.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const colors = ['red', 'green', 'blue', 'yellow']
56
+ * const randomColor = randomChoice(colors) // One of the colors
57
+ *
58
+ * const users = [{ name: 'Alice' }, { name: 'Bob' }]
59
+ * const randomUser = randomChoice(users) // One of the users
60
+ * ```
61
+ *
62
+ * @param array - The array to choose from
63
+ * @returns A random element from the array
64
+ * @throws Error if the array is empty
65
+ * @public
66
+ */
67
+ export declare const randomChoice: <T>(array: readonly T[]) => T;
68
+ /**
69
+ * Selects multiple random elements from an array without replacement.
70
+ *
71
+ * This function picks a specified number of unique elements from an array.
72
+ * The order of selected elements is randomized.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
77
+ * const sample = randomChoices(numbers, 3) // e.g., [7, 2, 9]
78
+ *
79
+ * const team = randomChoices(allPlayers, 5) // Pick 5 random players
80
+ * ```
81
+ *
82
+ * @param array - The array to choose from
83
+ * @param count - The number of elements to select
84
+ * @returns An array of randomly selected elements
85
+ * @throws Error if count is greater than array length or if array is empty
86
+ * @public
87
+ */
88
+ export declare const randomChoices: <T>(array: readonly T[], count: number) => T[];
89
+ /**
90
+ * Generates a random UUID v4 string.
91
+ *
92
+ * This function creates a UUID (Universally Unique Identifier) using
93
+ * random numbers. While not cryptographically secure, it's suitable
94
+ * for most application needs.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const id = randomUuid() // e.g., "f47ac10b-58cc-4372-a567-0e02b2c3d479"
99
+ * const sessionId = randomUuid()
100
+ * ```
101
+ *
102
+ * @returns A random UUID v4 string
103
+ * @public
104
+ */
105
+ export declare const randomUuid: () => string;
106
+ /**
107
+ * Generates a random hexadecimal string of specified length.
108
+ *
109
+ * This function creates a random string using hexadecimal characters (0-9, a-f).
110
+ * Useful for generating tokens, IDs, or other random identifiers.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const token = randomHex(16) // e.g., "a1b2c3d4e5f67890"
115
+ * const color = '#' + randomHex(6) // Random hex color
116
+ * ```
117
+ *
118
+ * @param length - The length of the hex string to generate
119
+ * @returns A random hexadecimal string
120
+ * @public
121
+ */
122
+ export declare const randomHex: (length: number) => string;
123
+ /**
124
+ * Generates random bytes as a Uint8Array.
125
+ *
126
+ * This function creates an array of random bytes, useful for
127
+ * cryptographic operations or when you need raw random data.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const key = randomBytes(32) // 32 random bytes
132
+ * const salt = randomBytes(16) // 16 random bytes for salt
133
+ * ```
134
+ *
135
+ * @param length - The number of bytes to generate
136
+ * @returns A Uint8Array containing random bytes
137
+ * @public
138
+ */
139
+ export declare const randomBytes: (length: number) => Uint8Array;
140
+ /**
141
+ * Creates a seeded random number generator.
142
+ *
143
+ * This function returns a deterministic random number generator
144
+ * that produces the same sequence of numbers for the same seed.
145
+ * Useful for testing or when reproducible randomness is needed.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const rng = seedRandom('my-seed')
150
+ * const num1 = rng() // Always the same for this seed
151
+ * const num2 = rng() // Next number in sequence
152
+ *
153
+ * // Create another generator with same seed
154
+ * const rng2 = seedRandom('my-seed')
155
+ * const same1 = rng2() // Same as num1
156
+ * ```
157
+ *
158
+ * @param seed - The seed string for the random number generator
159
+ * @returns A function that generates seeded random numbers between 0 and 1
160
+ * @public
161
+ */
162
+ export declare const seedRandom: (seed: string) => (() => number);
163
+ /**
164
+ * Shuffles an array in place using the Fisher-Yates algorithm.
165
+ *
166
+ * This function randomly reorders the elements of an array,
167
+ * modifying the original array. Each permutation is equally likely.
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const deck = ['A', 'K', 'Q', 'J', '10', '9', '8', '7']
172
+ * shuffle(deck) // deck is now randomly ordered
173
+ *
174
+ * const playlist = [...songs]
175
+ * shuffle(playlist) // Randomize playlist order
176
+ * ```
177
+ *
178
+ * @param array - The array to shuffle (modified in place)
179
+ * @returns The same array reference (for chaining)
180
+ * @public
181
+ */
182
+ export declare const shuffle: <T>(array: T[]) => T[];
183
+ /**
184
+ * Returns a shuffled copy of an array without modifying the original.
185
+ *
186
+ * This function creates a new array with the same elements as the input
187
+ * but in random order, leaving the original array unchanged.
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const original = [1, 2, 3, 4, 5]
192
+ * const shuffled = shuffled(original) // e.g., [3, 1, 5, 2, 4]
193
+ * // original is still [1, 2, 3, 4, 5]
194
+ * ```
195
+ *
196
+ * @param array - The array to shuffle
197
+ * @returns A new shuffled array
198
+ * @public
199
+ */
200
+ export declare const shuffled: <T>(array: readonly T[]) => T[];
package/random.js ADDED
@@ -0,0 +1,72 @@
1
+ const s = (t, r) => {
2
+ if (t > r)
3
+ throw new Error("min must be less than or equal to max");
4
+ return Math.floor(Math.random() * (r - t + 1)) + t;
5
+ }, c = (t, r, n = !1) => {
6
+ if (t > r)
7
+ throw new Error("min must be less than or equal to max");
8
+ const e = Math.random(), o = r - t;
9
+ return e * o + t;
10
+ }, h = (t) => {
11
+ if (t.length === 0)
12
+ throw new Error("Cannot choose from empty array");
13
+ const r = s(0, t.length - 1);
14
+ return t[r];
15
+ }, l = (t, r) => {
16
+ if (t.length === 0)
17
+ throw new Error("Cannot choose from empty array");
18
+ if (r > t.length)
19
+ throw new Error("Cannot select more elements than available in array");
20
+ if (r <= 0)
21
+ return [];
22
+ const n = [...t];
23
+ for (let e = n.length - 1; e > 0; e--) {
24
+ const o = s(0, e);
25
+ [n[e], n[o]] = [n[o], n[e]];
26
+ }
27
+ return n.slice(0, r);
28
+ }, a = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
29
+ const r = Math.random() * 16 | 0;
30
+ return (t === "x" ? r : r & 3 | 8).toString(16);
31
+ }), f = (t) => {
32
+ if (t <= 0)
33
+ return "";
34
+ const r = "0123456789abcdef";
35
+ let n = "";
36
+ for (let e = 0; e < t; e++)
37
+ n += r[s(0, r.length - 1)];
38
+ return n;
39
+ }, u = (t) => {
40
+ if (t <= 0)
41
+ return new Uint8Array(0);
42
+ const r = new Uint8Array(t);
43
+ for (let n = 0; n < t; n++)
44
+ r[n] = s(0, 255);
45
+ return r;
46
+ }, i = (t) => {
47
+ let r = 0;
48
+ for (let e = 0; e < t.length; e++) {
49
+ const o = t.charCodeAt(e);
50
+ r = (r << 5) - r + o, r = r & r;
51
+ }
52
+ let n = Math.abs(r);
53
+ return () => (n = (n * 1664525 + 1013904223) % 4294967296, n / 4294967296);
54
+ }, x = (t) => {
55
+ for (let r = t.length - 1; r > 0; r--) {
56
+ const n = s(0, r);
57
+ [t[r], t[n]] = [t[n], t[r]];
58
+ }
59
+ return t;
60
+ }, d = (t) => x([...t]);
61
+ export {
62
+ u as randomBytes,
63
+ h as randomChoice,
64
+ l as randomChoices,
65
+ c as randomFloat,
66
+ f as randomHex,
67
+ s as randomInt,
68
+ a as randomUuid,
69
+ i as seedRandom,
70
+ x as shuffle,
71
+ d as shuffled
72
+ };
package/set.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=(...t)=>{const r=new Set;for(const e of t)for(const s of e)r.add(s);return r},c=(t,r)=>{const e=new Set;for(const s of t)r.has(s)&&e.add(s);return e},f=(t,r)=>{const e=new Set;for(const s of t)r.has(s)||e.add(s);return e},i=(t,r)=>{const e=new Set;for(const s of t)r.has(s)||e.add(s);for(const s of r)t.has(s)||e.add(s);return e},o=(t,r)=>{for(const e of t)if(!r.has(e))return!1;return!0},a=(t,r)=>o(r,t),u=(t,r)=>{const e=new Set;for(const s of t)r(s)&&e.add(s);return e},m=(t,r)=>{const e=new Set;for(const s of t)e.add(r(s));return e},d=t=>t.size===0,S=t=>Array.from(t),l=t=>new Set(t);exports.setDifference=f;exports.setFilter=u;exports.setFromArray=l;exports.setIntersection=c;exports.setIsEmpty=d;exports.setIsSubset=o;exports.setIsSuperset=a;exports.setMap=m;exports.setSymmetricDifference=i;exports.setToArray=S;exports.setUnion=n;
package/set.d.ts ADDED
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Utilities for working with Set objects.
3
+ *
4
+ * This module provides mathematical set operations and functional utilities
5
+ * for Set manipulation, including union, intersection, difference, and
6
+ * various predicates and transformations.
7
+ *
8
+ * @public
9
+ */
10
+ /**
11
+ * Creates the union of multiple Sets.
12
+ *
13
+ * The union contains all unique elements that appear in any of the input Sets.
14
+ * This is equivalent to the mathematical union operation (A ∪ B ∪ C...).
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const setA = new Set([1, 2, 3])
19
+ * const setB = new Set([3, 4, 5])
20
+ * const setC = new Set([5, 6, 7])
21
+ * const union = setUnion(setA, setB, setC)
22
+ * // Result: Set { 1, 2, 3, 4, 5, 6, 7 }
23
+ * ```
24
+ *
25
+ * @param sets - Sets to union
26
+ * @returns A new Set containing all unique elements from input Sets
27
+ * @public
28
+ */
29
+ export declare const setUnion: <T>(...sets: Set<T>[]) => Set<T>;
30
+ /**
31
+ * Creates the intersection of two Sets.
32
+ *
33
+ * The intersection contains only elements that appear in both Sets.
34
+ * This is equivalent to the mathematical intersection operation (A ∩ B).
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const setA = new Set([1, 2, 3, 4])
39
+ * const setB = new Set([3, 4, 5, 6])
40
+ * const intersection = setIntersection(setA, setB)
41
+ * // Result: Set { 3, 4 }
42
+ * ```
43
+ *
44
+ * @param setA - First Set
45
+ * @param setB - Second Set
46
+ * @returns A new Set containing elements present in both input Sets
47
+ * @public
48
+ */
49
+ export declare const setIntersection: <T>(setA: Set<T>, setB: Set<T>) => Set<T>;
50
+ /**
51
+ * Creates the difference between two Sets.
52
+ *
53
+ * The difference contains elements that are in the first Set but not in the second.
54
+ * This is equivalent to the mathematical difference operation (A - B).
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const setA = new Set([1, 2, 3, 4])
59
+ * const setB = new Set([3, 4, 5, 6])
60
+ * const difference = setDifference(setA, setB)
61
+ * // Result: Set { 1, 2 }
62
+ * ```
63
+ *
64
+ * @param setA - Set to subtract from
65
+ * @param setB - Set to subtract
66
+ * @returns A new Set containing elements in setA but not in setB
67
+ * @public
68
+ */
69
+ export declare const setDifference: <T>(setA: Set<T>, setB: Set<T>) => Set<T>;
70
+ /**
71
+ * Creates the symmetric difference between two Sets.
72
+ *
73
+ * The symmetric difference contains elements that are in either Set but not in both.
74
+ * This is equivalent to (A - B) ∪ (B - A) or (A ∪ B) - (A ∩ B).
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const setA = new Set([1, 2, 3, 4])
79
+ * const setB = new Set([3, 4, 5, 6])
80
+ * const symDiff = setSymmetricDifference(setA, setB)
81
+ * // Result: Set { 1, 2, 5, 6 }
82
+ * ```
83
+ *
84
+ * @param setA - First Set
85
+ * @param setB - Second Set
86
+ * @returns A new Set containing elements in either Set but not both
87
+ * @public
88
+ */
89
+ export declare const setSymmetricDifference: <T>(setA: Set<T>, setB: Set<T>) => Set<T>;
90
+ /**
91
+ * Checks if one Set is a subset of another.
92
+ *
93
+ * A Set is a subset if all of its elements are contained in the other Set.
94
+ * An empty Set is considered a subset of any Set.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const subset = new Set([1, 2])
99
+ * const superset = new Set([1, 2, 3, 4])
100
+ * const notSubset = new Set([1, 5])
101
+ *
102
+ * setIsSubset(subset, superset) // true
103
+ * setIsSubset(notSubset, superset) // false
104
+ * setIsSubset(new Set(), superset) // true (empty set)
105
+ * ```
106
+ *
107
+ * @param subset - Set to check if it's a subset
108
+ * @param superset - Set to check against
109
+ * @returns true if subset is a subset of superset, false otherwise
110
+ * @public
111
+ */
112
+ export declare const setIsSubset: <T>(subset: Set<T>, superset: Set<T>) => boolean;
113
+ /**
114
+ * Checks if one Set is a superset of another.
115
+ *
116
+ * A Set is a superset if it contains all elements of the other Set.
117
+ * This is the inverse of the subset relationship.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const superset = new Set([1, 2, 3, 4])
122
+ * const subset = new Set([1, 2])
123
+ * const notSubset = new Set([1, 5])
124
+ *
125
+ * setIsSuperset(superset, subset) // true
126
+ * setIsSuperset(superset, notSubset) // false
127
+ * ```
128
+ *
129
+ * @param superset - Set to check if it's a superset
130
+ * @param subset - Set to check against
131
+ * @returns true if superset is a superset of subset, false otherwise
132
+ * @public
133
+ */
134
+ export declare const setIsSuperset: <T>(superset: Set<T>, subset: Set<T>) => boolean;
135
+ /**
136
+ * Creates a new Set containing only elements that satisfy the predicate.
137
+ *
138
+ * This provides a functional approach to filtering Sets, similar to
139
+ * Array.prototype.filter but for Set objects.
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const numbers = new Set([1, 2, 3, 4, 5, 6])
144
+ * const evenNumbers = setFilter(numbers, n => n % 2 === 0)
145
+ * // Result: Set { 2, 4, 6 }
146
+ * ```
147
+ *
148
+ * @param set - The Set to filter
149
+ * @param predicate - Function that tests each element
150
+ * @returns A new Set with elements that satisfy the predicate
151
+ * @public
152
+ */
153
+ export declare const setFilter: <T>(set: Set<T>, predicate: (value: T) => boolean) => Set<T>;
154
+ /**
155
+ * Creates a new Set with elements transformed by the mapper function.
156
+ *
157
+ * This provides a functional approach to transforming Set elements,
158
+ * similar to Array.prototype.map but for Set objects.
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * const numbers = new Set([1, 2, 3])
163
+ * const doubled = setMap(numbers, n => n * 2)
164
+ * // Result: Set { 2, 4, 6 }
165
+ * ```
166
+ *
167
+ * @param set - The Set to transform
168
+ * @param mapper - Function that transforms each element
169
+ * @returns A new Set with transformed elements
170
+ * @public
171
+ */
172
+ export declare const setMap: <T, U>(set: Set<T>, mapper: (value: T) => U) => Set<U>;
173
+ /**
174
+ * Checks if a Set is empty.
175
+ *
176
+ * This provides a semantic way to check for empty Sets,
177
+ * making code more readable than checking size === 0.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const emptySet = new Set()
182
+ * const nonEmptySet = new Set([1, 2, 3])
183
+ *
184
+ * setIsEmpty(emptySet) // true
185
+ * setIsEmpty(nonEmptySet) // false
186
+ * ```
187
+ *
188
+ * @param set - The Set to check
189
+ * @returns true if the Set has no elements, false otherwise
190
+ * @public
191
+ */
192
+ export declare const setIsEmpty: <T>(set: Set<T>) => boolean;
193
+ /**
194
+ * Converts a Set to an array.
195
+ *
196
+ * This provides a convenient way to convert Sets to arrays
197
+ * for further processing with array methods.
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * const set = new Set([3, 1, 4, 1, 5]) // Note: duplicates are removed
202
+ * const array = setToArray(set)
203
+ * // Result: [3, 1, 4, 5]
204
+ * ```
205
+ *
206
+ * @param set - The Set to convert
207
+ * @returns An array containing all elements from the Set
208
+ * @public
209
+ */
210
+ export declare const setToArray: <T>(set: Set<T>) => T[];
211
+ /**
212
+ * Creates a Set from an array, removing duplicates.
213
+ *
214
+ * This provides a semantic way to deduplicate arrays using Sets.
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const array = [1, 2, 2, 3, 3, 3, 4]
219
+ * const set = setFromArray(array)
220
+ * // Result: Set { 1, 2, 3, 4 }
221
+ * ```
222
+ *
223
+ * @param array - The array to convert
224
+ * @returns A new Set containing unique elements from the array
225
+ * @public
226
+ */
227
+ export declare const setFromArray: <T>(array: readonly T[]) => Set<T>;
package/set.js ADDED
@@ -0,0 +1,52 @@
1
+ const r = (...t) => {
2
+ const o = /* @__PURE__ */ new Set();
3
+ for (const e of t)
4
+ for (const s of e)
5
+ o.add(s);
6
+ return o;
7
+ }, c = (t, o) => {
8
+ const e = /* @__PURE__ */ new Set();
9
+ for (const s of t)
10
+ o.has(s) && e.add(s);
11
+ return e;
12
+ }, f = (t, o) => {
13
+ const e = /* @__PURE__ */ new Set();
14
+ for (const s of t)
15
+ o.has(s) || e.add(s);
16
+ return e;
17
+ }, i = (t, o) => {
18
+ const e = /* @__PURE__ */ new Set();
19
+ for (const s of t)
20
+ o.has(s) || e.add(s);
21
+ for (const s of o)
22
+ t.has(s) || e.add(s);
23
+ return e;
24
+ }, n = (t, o) => {
25
+ for (const e of t)
26
+ if (!o.has(e))
27
+ return !1;
28
+ return !0;
29
+ }, a = (t, o) => n(o, t), u = (t, o) => {
30
+ const e = /* @__PURE__ */ new Set();
31
+ for (const s of t)
32
+ o(s) && e.add(s);
33
+ return e;
34
+ }, d = (t, o) => {
35
+ const e = /* @__PURE__ */ new Set();
36
+ for (const s of t)
37
+ e.add(o(s));
38
+ return e;
39
+ }, m = (t) => t.size === 0, S = (t) => Array.from(t), l = (t) => new Set(t);
40
+ export {
41
+ f as setDifference,
42
+ u as setFilter,
43
+ l as setFromArray,
44
+ c as setIntersection,
45
+ m as setIsEmpty,
46
+ n as setIsSubset,
47
+ a as setIsSuperset,
48
+ d as setMap,
49
+ i as setSymmetricDifference,
50
+ S as setToArray,
51
+ r as setUnion
52
+ };
package/string.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./array.cjs"),m=require("./error.cjs"),A=require("./regexp.cjs"),u=(t,e,n)=>t.split(e).join(n),_=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(n+e.length)},k=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(n+e.length)},H=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(0,n)},$=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(0,n)},h=t=>t.substring(0,1).toUpperCase()+t.substring(1),b=t=>t.toUpperCase(),D=(t,e=!1)=>e?A.mapRegExp(h(t),qt,b):A.mapRegExp(h(t),$t,b),R=t=>t.replace(Qt,`
2
- `),q=(t,e)=>t==null&&e==null?0:t==null?-1:e==null?1:I(t.toLowerCase(),e.toLowerCase()),d=(t,e)=>t.substring(0,t.length-e.length)===e,P=(t,e)=>t.substring(0,t.length-e.length).toLowerCase()===e.toLowerCase(),L=(t,e)=>t.substring(0,e.length)===e,Z=(t,e)=>t.substring(0,e.length).toLowerCase()===e.toLowerCase(),Q=(t,e)=>y(t.toLowerCase(),e.map(n=>n.toLowerCase())),G=(t,e)=>B(t.toLowerCase(),e.map(n=>n.toLowerCase())),K=t=>t.trim().replace(F," "),I=(t,e)=>t<e?-1:t>e?1:0,C=(t,e)=>t.toLowerCase().includes(e.toLowerCase()),l=(t,e)=>t.includes(e),J=(t,e)=>t.split(e).length-1,V=(t,e)=>c.anyElement(e,n=>C(t,n)),X=(t,e)=>c.anyElement(e,n=>l(t,n)),Y=(t,e)=>c.allElements(e,n=>C(t,n)),v=(t,e)=>c.allElements(e,n=>l(t,n)),tt=t=>t.replace("_","-"),et=(t,e)=>{if(t===e)return-1;const n=Math.min(t.length,e.length);for(let r=0;r<n;r++)if(t.substring(r,r+1)!==e.substring(r,r+1))return r;return n},w=(t,e=20,n="…")=>{const r=t.length,s=n.length;return r>e?e<s?n.slice(s-e,e):t.slice(0,e-s)+n:t},nt=(t,e=20,n="…")=>{const r=t.length,s=n.length;if(r>e){if(e<=s)return w(t,e,n);const a=Math.ceil((e-s)/2),g=Math.floor((e-s)/2);return t.slice(0,a)+n+t.slice(r-g)}else return t},y=(t,e)=>c.anyElement(e,n=>d(t,n)),rt=(t,e)=>p(t).filter(e).join(""),st=(t,e)=>T(t).filter(e).map(r=>String.fromCharCode(r)).join(""),it=(t,e=2166136261)=>{let n=e;for(let r=0,s=t.length;r<s;r++)n^=t.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0},ot=t=>t!=null&&t.length>0,ct=t=>u(M(t),"_"," "),at=t=>t.length>0&&!Rt.test(t),ut=t=>Pt.test(t),lt=t=>!Dt.test(t),gt=t=>t.toLowerCase()===t,pt=t=>t.toUpperCase()===t,ht=(t,e)=>t!=null&&t!==""?t:e,ft=t=>Zt.test(t),dt=t=>t==null||t==="",Ct=t=>t.substring(0,1).toLowerCase()+t.substring(1),E=(t,e=1)=>t.substring(Math.floor((t.length-e+1)*Math.random()),e),x=(t,e)=>c.generateArray(e,()=>E(t)).join(""),St=t=>x(Ht,t),At=(t,e)=>p(e).map(t),bt=(t,e)=>u(t,e,""),mt=(t,e)=>d(t,e)?t.substring(0,t.length-e.length):t,Lt=(t,e,n)=>t.substring(0,e)+t.substring(e+n),It=(t,e)=>L(t,e)?t.substring(e.length):t,wt=(t,e)=>{const n=t.indexOf(e);return n<0?t:t.substring(0,n)+t.substring(n+e.length)},S=(t,e)=>c.createFilledArray(e,t).join(""),yt=t=>{const e=p(t);return e.reverse(),e.join("")},W=(t,e="'")=>e==="'"?t.includes("'")?t.includes('"')?"'"+u(t,"'","\\'")+"'":'"'+t+'"':"'"+t+"'":t.includes('"')?t.includes("'")?'"'+u(t,'"','\\"')+'"':"'"+t+"'":'"'+t+'"',O=(t,e="'")=>e+u(t,e,"\\"+e)+e,Et=(t,e="'")=>t.indexOf(`
3
- `)>=0?O(t,"`"):W(t,e),xt=(t,e)=>{const n=t.indexOf(e);return n<0?[t]:[t.substring(0,n),t.substring(n+e.length)]},B=(t,e)=>c.anyElement(e,n=>t.startsWith(n)),Wt=(t,e,n=e)=>`${e}${t}${n}`,p=t=>t.split(""),T=t=>c.generateArray(t.length,e=>t.charCodeAt(e)),Ot=(t,e)=>{const n=[];for(;t.length>0;)n.push(t.substring(0,e)),t=t.substring(e,t.length-e);return n},Bt=t=>t.split(U),Tt=(t,e)=>j(z(t,e),e),z=(t,e)=>{let n=0;for(let r=0;r<t.length&&l(e,t.charAt(r));r++)n++;return t.substring(n)},j=(t,e)=>{const n=t.length;let r=n,s;for(let a=0;a<n&&(s=n-a-1,l(e,t.charAt(s)));a++)r=s;return t.substring(0,r)},M=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()),zt=t=>t.substring(0,1).toUpperCase()+t.substring(1),jt=(t,e=78,n="",r=`
4
- `)=>t.split(U).map(s=>N(s.replace(F," ").trim(),e,n,r)).join(r),f=(t,e)=>{if(e<0||e>=t.length)return!1;const n=t.charCodeAt(e);return n===9||n===10||n===11||n===12||n===13||n===32},Mt=t=>{if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof btoa<"u")return btoa(t);throw new m.MissingImplementationError("No implementation found for base64 encoding")},Nt=t=>{if(typeof Buffer<"u")return Buffer.from(t,"base64").toString("utf8");if(typeof atob<"u")return atob(t);throw new m.MissingImplementationError("No implementation found for base64 decoding")},N=(t,e,n,r)=>{const s=[],a=t.length,g=n.length;let o=0;for(e-=g;;){if(o+e>=a-g){s.push(t.substring(o));break}let i=0;for(;!f(t,o+e-i)&&i<e;)i++;if(i===e){for(i=0;!f(t,o+e+i)&&o+e+i<a;)i++;s.push(t.substring(o,o+e+i)),o+=e+i+1}else s.push(t.substring(o,o+e-i)),o+=e-i+1}return n+s.join(r+n)},Ft=(t,e,n)=>{const r=n-t.length;return r>0?S(e,r)+t:t},Ut=(t,e,n)=>{const r=n-t.length;return r>0?t+S(e,r):t},_t=(t,e)=>{const n=t.lastIndexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},kt=(t,e)=>{const n=t.indexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$t=/[^a-zA-Z]([a-z])/g,Dt=/[^\t\n\r ]/,Rt=/[^a-zA-Z]/,qt=/[ \t\r\n][a-z]/g,Pt=/^[a-z0-9]+$/i,Zt=/^[0-9]+$/,F=/[ \t\r\n]+/g,U=/\r\n|\n\r|\n|\r/g,Qt=/\r\n|\n\r|\r/g;exports.canonicalizeNewlines=R;exports.capitalize=h;exports.capitalizeWords=D;exports.chunkString=Ot;exports.collapseText=K;exports.compareCaseInsensitive=q;exports.compareStrings=I;exports.containsAllText=v;exports.containsAllTextCaseInsensitive=Y;exports.containsAnyText=X;exports.containsAnyTextCaseInsensitive=V;exports.countStringOccurrences=J;exports.dasherize=tt;exports.decodeBase64=Nt;exports.deleteFirstFromString=wt;exports.deleteStringAfter=mt;exports.deleteStringBefore=It;exports.deleteSubstring=bt;exports.ellipsis=w;exports.ellipsisMiddle=nt;exports.encodeBase64=Mt;exports.filterCharcodes=st;exports.filterChars=rt;exports.humanize=ct;exports.ifEmptyString=ht;exports.isAlpha=at;exports.isAlphaNum=ut;exports.isBreakingWhitespace=lt;exports.isDigitsOnly=ft;exports.isEmptyString=dt;exports.isLowerCase=gt;exports.isSpaceAt=f;exports.isUpperCase=pt;exports.jsQuote=Et;exports.lowerCaseFirst=Ct;exports.lpad=Ft;exports.mapChars=At;exports.quote=O;exports.randomString=E;exports.randomStringSequence=x;exports.randomStringSequenceBase64=St;exports.repeatString=S;exports.replaceAll=u;exports.reverseString=yt;exports.rpad=Ut;exports.smartQuote=W;exports.splitStringOnFirst=kt;exports.splitStringOnLast=_t;exports.splitStringOnce=xt;exports.stringContains=l;exports.stringEndsWith=d;exports.stringEndsWithAny=y;exports.stringHasContent=ot;exports.stringHashCode=it;exports.stringStartsWith=L;exports.stringStartsWithAny=B;exports.stringToCharcodes=T;exports.stringToChars=p;exports.stringsDifferAtIndex=et;exports.substringAfter=_;exports.substringAfterLast=k;exports.substringBefore=H;exports.substringBeforeLast=$;exports.surroundString=Wt;exports.textContainsCaseInsensitive=C;exports.textEndsWithAnyCaseInsensitive=Q;exports.textEndsWithCaseInsensitive=P;exports.textStartsWithAnyCaseInsensitive=G;exports.textStartsWithCaseInsensitive=Z;exports.textToLines=Bt;exports.trimChars=Tt;exports.trimCharsLeft=z;exports.trimCharsRight=j;exports.trimStringSlice=Lt;exports.underscore=M;exports.upperCaseFirst=zt;exports.wrapColumns=jt;exports.wrapLine=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./error.cjs"),f=require("./regexp.cjs"),T=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(n+e.length)},z=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(n+e.length)},j=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(0,n)},M=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(0,n)},a=t=>t.substring(0,1).toUpperCase()+t.substring(1),p=t=>t.toUpperCase(),N=(t,e=!1)=>e?f.mapRegExp(a(t),Ut,p):f.mapRegExp(a(t),Mt,p),_=t=>t.replace(Ht,`
2
+ `),U=(t,e)=>t==null&&e==null?0:t==null?-1:e==null?1:d(t.toLowerCase(),e.toLowerCase()),k=(t,e)=>t.substring(t.length-e.length).toLowerCase()===e.toLowerCase(),F=(t,e)=>t.substring(0,e.length).toLowerCase()===e.toLowerCase(),H=(t,e)=>S(t.toLowerCase(),e.map(n=>n.toLowerCase())),$=(t,e)=>I(t.toLowerCase(),e.map(n=>n.toLowerCase())),D=t=>t.trim().replace(E," "),d=(t,e)=>t<e?-1:t>e?1:0,g=(t,e)=>t.toLowerCase().includes(e.toLowerCase()),R=(t,e)=>t.split(e).length-1,P=(t,e)=>e.some(n=>g(t,n)),Z=(t,e)=>e.some(n=>t.includes(n)),q=(t,e)=>e.every(n=>g(t,n)),Q=(t,e)=>e.every(n=>t.includes(n)),G=t=>t.replace(/_/g,"-"),K=(t,e)=>{if(t===e)return-1;const n=Math.min(t.length,e.length);for(let r=0;r<n;r++)if(t.substring(r,r+1)!==e.substring(r,r+1))return r;return n},C=(t,e=20,n="…")=>{const r=t.length,s=n.length;return r>e?e<s?n.slice(s-e,e):t.slice(0,e-s)+n:t},J=(t,e=20,n="…")=>{const r=t.length,s=n.length;if(r>e){if(e<=s)return C(t,e,n);const c=Math.ceil((e-s)/2),u=Math.floor((e-s)/2);return t.slice(0,c)+n+t.slice(r-u)}else return t},S=(t,e)=>e.some(n=>t.endsWith(n)),V=(t,e)=>Array.from(t).filter(e).join(""),X=(t,e)=>w(t).filter(e).map(r=>String.fromCharCode(r)).join(""),Y=(t,e=2166136261)=>{let n=e;for(let r=0,s=t.length;r<s;r++)n^=t.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0},v=t=>t!=null&&t.length>0,tt=t=>W(t).split("_").join(" "),et=t=>t.length>0&&!_t.test(t),nt=t=>kt.test(t),rt=t=>!Nt.test(t),st=t=>t.toLowerCase()===t,it=t=>t.toUpperCase()===t,ot=(t,e)=>t!=null&&t!==""?t:e,ct=t=>Ft.test(t),ut=t=>t==null||t==="",at=t=>t.substring(0,1).toLowerCase()+t.substring(1),A=(t,e=1)=>{const n=Math.floor((t.length-e+1)*Math.random());return t.substring(n,n+e)},b=(t,e)=>Array.from({length:e},()=>A(t)).join(""),lt=t=>b(jt,t),gt=(t,e)=>Array.from(e).map(t),ft=(t,e)=>t.split(e).join(""),pt=(t,e)=>t.endsWith(e)?t.substring(0,t.length-e.length):t,ht=(t,e,n)=>t.substring(0,e)+t.substring(e+n),dt=(t,e)=>t.startsWith(e)?t.substring(e.length):t,Ct=(t,e)=>{const n=t.indexOf(e);return n<0?t:t.substring(0,n)+t.substring(n+e.length)},St=t=>{const e=Array.from(t);return e.reverse(),e.join("")},m=(t,e="'")=>e==="'"?t.includes("'")?t.includes('"')?"'"+t.split("'").join("\\'")+"'":'"'+t+'"':"'"+t+"'":t.includes('"')?t.includes("'")?'"'+t.split('"').join('\\"')+'"':"'"+t+"'":'"'+t+'"',L=(t,e="'")=>e+t.split(e).join("\\"+e)+e,At=(t,e="'")=>t.indexOf(`
3
+ `)>=0?L(t,"`"):m(t,e),bt=(t,e)=>{const n=t.indexOf(e);return n<0?[t]:[t.substring(0,n),t.substring(n+e.length)]},I=(t,e)=>e.some(n=>t.startsWith(n)),mt=(t,e,n=e)=>`${e}${t}${n}`,w=t=>Array.from({length:t.length},(e,n)=>t.charCodeAt(n)),Lt=(t,e)=>{const n=[];for(;t.length>0;)n.push(t.substring(0,e)),t=t.substring(e,t.length-e);return n},It=t=>t.split(B),wt=(t,e)=>y(x(t,e),e),x=(t,e)=>{let n=0;for(let r=0;r<t.length&&e.includes(t.charAt(r));r++)n++;return t.substring(n)},y=(t,e)=>{const n=t.length;let r=n,s;for(let c=0;c<n&&(s=n-c-1,e.includes(t.charAt(s)));c++)r=s;return t.substring(0,r)},W=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()),xt=t=>t.substring(0,1).toUpperCase()+t.substring(1),yt=(t,e=78,n="",r=`
4
+ `)=>t.split(B).map(s=>O(s.replace(E," ").trim(),e,n,r)).join(r),l=(t,e)=>{if(e<0||e>=t.length)return!1;const n=t.charCodeAt(e);return n===9||n===10||n===11||n===12||n===13||n===32},Wt=t=>{if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof btoa<"u")return btoa(t);throw new h.MissingImplementationError("No implementation found for base64 encoding")},Ot=t=>{if(typeof Buffer<"u")return Buffer.from(t,"base64").toString("utf8");if(typeof atob<"u")return atob(t);throw new h.MissingImplementationError("No implementation found for base64 decoding")},O=(t,e,n,r)=>{const s=[],c=t.length,u=n.length;let o=0;for(e-=u;;){if(o+e>=c-u){s.push(t.substring(o));break}let i=0;for(;!l(t,o+e-i)&&i<e;)i++;if(i===e){for(i=0;!l(t,o+e+i)&&o+e+i<c;)i++;s.push(t.substring(o,o+e+i)),o+=e+i+1}else s.push(t.substring(o,o+e-i)),o+=e-i+1}return n+s.join(r+n)},Et=(t,e,n)=>{const r=n-t.length;return r>0?e.repeat(r)+t:t},Bt=(t,e,n)=>{const r=n-t.length;return r>0?t+e.repeat(r):t},Tt=(t,e)=>{const n=t.lastIndexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},zt=(t,e)=>{const n=t.indexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Mt=/[^a-zA-Z]([a-z])/g,Nt=/[^\t\n\r ]/,_t=/[^a-zA-Z]/,Ut=/[ \t\r\n][a-z]/g,kt=/^[a-z0-9]+$/i,Ft=/^[0-9]+$/,E=/[ \t\r\n]+/g,B=/\r\n|\n\r|\n|\r/g,Ht=/\r\n|\n\r|\r/g;exports.canonicalizeNewlines=_;exports.capitalize=a;exports.capitalizeWords=N;exports.chunkString=Lt;exports.collapseText=D;exports.compareCaseInsensitive=U;exports.compareStrings=d;exports.containsAllText=Q;exports.containsAllTextCaseInsensitive=q;exports.containsAnyText=Z;exports.containsAnyTextCaseInsensitive=P;exports.countStringOccurrences=R;exports.dasherize=G;exports.decodeBase64=Ot;exports.deleteFirstFromString=Ct;exports.deleteStringAfter=pt;exports.deleteStringBefore=dt;exports.deleteSubstring=ft;exports.ellipsis=C;exports.ellipsisMiddle=J;exports.encodeBase64=Wt;exports.filterCharcodes=X;exports.filterChars=V;exports.humanize=tt;exports.ifEmptyString=ot;exports.isAlpha=et;exports.isAlphaNum=nt;exports.isBreakingWhitespace=rt;exports.isDigitsOnly=ct;exports.isEmptyString=ut;exports.isLowerCase=st;exports.isSpaceAt=l;exports.isUpperCase=it;exports.jsQuote=At;exports.lowerCaseFirst=at;exports.lpad=Et;exports.mapChars=gt;exports.quote=L;exports.randomStringSequence=b;exports.randomStringSequenceBase64=lt;exports.randomSubString=A;exports.reverseString=St;exports.rpad=Bt;exports.smartQuote=m;exports.splitStringOnFirst=zt;exports.splitStringOnLast=Tt;exports.splitStringOnce=bt;exports.stringEndsWithAny=S;exports.stringHasContent=v;exports.stringHashCode=Y;exports.stringStartsWithAny=I;exports.stringToCharcodes=w;exports.stringsDifferAtIndex=K;exports.substringAfter=T;exports.substringAfterLast=z;exports.substringBefore=j;exports.substringBeforeLast=M;exports.surroundString=mt;exports.textContainsCaseInsensitive=g;exports.textEndsWithAnyCaseInsensitive=H;exports.textEndsWithCaseInsensitive=k;exports.textStartsWithAnyCaseInsensitive=$;exports.textStartsWithCaseInsensitive=F;exports.textToLines=It;exports.trimChars=wt;exports.trimCharsLeft=x;exports.trimCharsRight=y;exports.trimStringSlice=ht;exports.underscore=W;exports.upperCaseFirst=xt;exports.wrapColumns=yt;exports.wrapLine=O;