qznt 1.0.36 → 2.0.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.
@@ -0,0 +1,670 @@
1
+ declare class Cache<T> {
2
+ private cache;
3
+ private interval;
4
+ /**
5
+ * A lightweight, high-performant in-memory cache.
6
+ * Uses Map for O(1) lookups and an optional cleanup interval.
7
+ * @param cleanupMs The interval in milliseconds to run the cleanup function. [default: 60000 (1 minute)]
8
+ */
9
+ constructor(cleanupMs?: number);
10
+ set(key: string | number, value: T, ttlMs?: number): void;
11
+ get(key: string | number): T | null;
12
+ private cleanup;
13
+ clear(): void;
14
+ }
15
+
16
+ type AnyFunc = (...args: any) => any;
17
+ type DeepPartial<T> = {
18
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
19
+ };
20
+ type TypedEmitter<TEvents extends Record<string, any>> = {
21
+ on<K extends keyof TEvents>(event: K, listener: (...args: TEvents[K]) => void): any;
22
+ once<K extends keyof TEvents>(event: K, listener: (...args: TEvents[K]) => void): any;
23
+ off<K extends keyof TEvents>(event: K, listener: (...args: TEvents[K]) => void): any;
24
+ emit<K extends keyof TEvents>(event: K, ...args: TEvents[K]): boolean;
25
+ };
26
+
27
+ type LoopState = "running" | "paused" | "stopped";
28
+ interface LoopEvents<T> {
29
+ start: [];
30
+ tick: [result: T];
31
+ pause: [{
32
+ remaining: number;
33
+ }];
34
+ resume: [];
35
+ stop: [];
36
+ error: [error: unknown];
37
+ }
38
+ declare const TypedEmitterBase: {
39
+ new <T>(): TypedEmitter<LoopEvents<T>>;
40
+ };
41
+ declare class Loop<T = unknown> extends TypedEmitterBase<T> {
42
+ private _state;
43
+ private timeoutId;
44
+ private delay;
45
+ private fn;
46
+ private startTime;
47
+ private remaining;
48
+ private run;
49
+ private clearTimer;
50
+ /**
51
+ * Creates an interval. If the function is async, it will wait for it to complete before scheduling the next run.
52
+ * @param fn The function to run.
53
+ * @param delay The delay between runs in milliseconds.
54
+ * @param immediate Whether to start the loop immediately. [default: true]
55
+ */
56
+ constructor(fn: (loop: Loop<T>) => Promise<T> | T, delay: number, immediate?: boolean);
57
+ get state(): LoopState;
58
+ /** Starts the loop. */
59
+ start(): void;
60
+ /** Resumes a paused loop. */
61
+ resume(): void;
62
+ /** Stops the loop. */
63
+ stop(): void;
64
+ /** Pauses the execution. */
65
+ pause(): void;
66
+ /**
67
+ * Sets the delay between runs
68
+ * @param ms The new delay in milliseconds.
69
+ */
70
+ setDelay(ms: number): void;
71
+ /** Manually trigger the function once without affecting the loop. */
72
+ execute(): Promise<void>;
73
+ }
74
+
75
+ /**
76
+ * Pipes a value through a series of functions.
77
+ * Each function takes the output of the previous one.
78
+ */
79
+ declare function Pipe<A>(value: A): A;
80
+ declare function Pipe<A, B>(value: A, fn1: (arg: A) => B): B;
81
+ declare function Pipe<A, B, C>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C): C;
82
+ declare function Pipe<A, B, C, D>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D): D;
83
+ declare function Pipe<A, B, C, D, E>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D, fn4: (arg: D) => E): E;
84
+ declare function Pipe<A, B, C, D, E, F>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D, fn4: (arg: D) => E, fn5: (arg: E) => F): F;
85
+ declare function Pipe<A, B, C, D, E, F, G>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D, fn4: (arg: D) => E, fn5: (arg: E) => F, fn6: (arg: F) => G): G;
86
+ declare function Pipe<A, B, C, D, E, F, G, H>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D, fn4: (arg: D) => E, fn5: (arg: E) => F, fn6: (arg: F) => G, fn7: (arg: G) => H): H;
87
+ declare function Pipe<A, B, C, D, E, F, G, H, I>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D, fn4: (arg: D) => E, fn5: (arg: E) => F, fn6: (arg: F) => G, fn7: (arg: G) => H, fn8: (arg: H) => I): I;
88
+ declare function Pipe<A, B, C, D, E, F, G, H, I, J>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D, fn4: (arg: D) => E, fn5: (arg: E) => F, fn6: (arg: F) => G, fn7: (arg: G) => H, fn8: (arg: H) => I, fn9: (arg: I) => J): J;
89
+ declare function Pipe<A, B, C, D, E, F, G, H, I, J, K>(value: A, fn1: (arg: A) => B, fn2: (arg: B) => C, fn3: (arg: C) => D, fn4: (arg: D) => E, fn5: (arg: E) => F, fn6: (arg: F) => G, fn7: (arg: G) => H, fn8: (arg: H) => I, fn9: (arg: I) => J, fn10: (arg: J) => K): K;
90
+
91
+ declare class Storage {
92
+ private isNode;
93
+ private filePath;
94
+ private memoryCache;
95
+ private loadFromFile;
96
+ private persist;
97
+ /**
98
+ * A lightweight, high-performant persistent storage system.
99
+ * Uses JSON files in Node.js, localStorage in the browser
100
+ * @param fileName Only used in Node.js to create a persistent .json file
101
+ * @param directory The directory for the file. Defaults to current working directory
102
+ */
103
+ constructor(fileName?: string, directory?: string);
104
+ has(key: string): boolean;
105
+ get<T>(key: string): T | null;
106
+ set<T>(key: string, value: T, ttl?: number): void;
107
+ remove(key: string): void;
108
+ clear(): void;
109
+ }
110
+
111
+ type SequentialMapContext<T, U> = {
112
+ index: number;
113
+ lastElement: U | undefined;
114
+ newArray: ReadonlyArray<U>;
115
+ originalArray: ReadonlyArray<T>;
116
+ };
117
+ /**
118
+ * Splits an array into sub-arrays (chunks) of a maximum size.
119
+ * @param array Array to process
120
+ * @param size The maximum size of each chunk
121
+ */
122
+ declare function chunk<T>(array: ReadonlyArray<T>, size: number): T[][];
123
+ /**
124
+ * Groups adjacent elements of an array together based on a predicate.
125
+ * @param array Array to process
126
+ * @param predicate A function that returns true if two adjacent elements belong in the same chunk
127
+ * @example
128
+ * // Group consecutive identical numbers
129
+ * chunkBy([1, 1, 2, 3, 3, 3], (a, b) => a === b);
130
+ * // [[1, 1], [2], [3, 3, 3]]
131
+ */
132
+ declare function chunkAdj<T>(array: ReadonlyArray<T>, predicate: (prev: T, curr: T) => boolean): T[][];
133
+ /**
134
+ * Groups elements by a key.
135
+ * @param array Array to process
136
+ * @param iteratee Function to determine the key to group by
137
+ * @param maxChunkSize Optionally chunk groups and flatten them (useful for pagination)
138
+ */
139
+ declare function cluster<T>(array: ReadonlyArray<T>, iteratee: (item: T) => string | number, maxChunkSize?: number): T[][];
140
+ /**
141
+ * Removes unwanted values from an array.
142
+ * @param array Array to process
143
+ * @param mode 'nullable' (default) removes null/undefined. 'falsy' removes null, undefined, 0, "", false, and NaN
144
+ */
145
+ declare function compactArray<T>(array: ReadonlyArray<T>, mode?: "nullable"): NonNullable<T>[];
146
+ declare function compactArray<T>(array: ReadonlyArray<T>, mode: "falsy"): Exclude<T, null | undefined | false | 0 | "">[];
147
+ /**
148
+ * Forces a given item to be an array.
149
+ * @param item The item to force into an array.
150
+ */
151
+ declare function forceArray<T>(item: T): T[];
152
+ /**
153
+ * Searches a sorted array for a value using the binary search method.
154
+ * Returns the index if found, or the bitwise complement (~index) of the
155
+ * position where the value should be inserted to keep it sorted.
156
+ * @param array The array to process
157
+ * @param target The value to search for
158
+ * @param comparator Optional comparator function
159
+ */
160
+ declare function searchSorted<T>(array: T[], target: T, comparator?: (a: T, b: T) => number): number;
161
+ /**
162
+ * Maps over an array with access to the previously mapped elements.
163
+ * @param array Array to process
164
+ * @param callback Function to map over the array
165
+ */
166
+ declare function seqMap<T, U>(array: ReadonlyArray<T>, callback: (item: T, context: SequentialMapContext<T, U>) => U): U[];
167
+ /**
168
+ * Shuffles an array using the Fisher-Yates algorithm.
169
+ * @param array The array to shuffle
170
+ * @param seed Optional seed for RNG
171
+ */
172
+ declare function shuffle<T>(array: ReadonlyArray<T>, seed?: number): T[];
173
+ /**
174
+ * Sorts an array by a single property in order.
175
+ * @param order 'asc' for ascending (default) or 'desc' for descending
176
+ * @param array Array to process
177
+ * @param selector Function to determine the key to sort by
178
+ */
179
+ declare function sortBy<T>(array: ReadonlyArray<T>, selector: (item: T) => any, order?: "asc" | "desc"): T[];
180
+ /**
181
+ * Sorts an array by one or more properties in order.
182
+ * @param order 'asc' for ascending (default) or 'desc' for descending
183
+ * @param array Array to process
184
+ * @param selectors Functions to determine the keys to sort by
185
+ */
186
+ declare function sortBy<T>(array: ReadonlyArray<T>, selectors: (item: T) => any[], order?: "asc" | "desc"): T[];
187
+ /**
188
+ * Returns an array of unique elements from the given array.
189
+ * Uniqueness is determined by the given key function.
190
+ * @param array Array to process
191
+ * @param key Function to determine the keys to filter by
192
+ */
193
+ declare function unique<T>(array: T[], key: (item: T) => any): T[];
194
+
195
+ interface RetryOptions {
196
+ /** Maximum number of retry attempts. @default 3 */
197
+ attempts?: number;
198
+ /** Base retry delay in milliseconds. @default 500 */
199
+ delay?: number;
200
+ /** Timeout in milliseconds for each attempt. */
201
+ timeout?: number;
202
+ /** An AbortSignal to cancel the entire operation. */
203
+ signal?: AbortSignal;
204
+ }
205
+ /**
206
+ * Retries an async function until the maximum number of attempts is reached.
207
+ *
208
+ * Implements exponential backoff with random jitter.
209
+ * @param fn The asynchronous function to attempt
210
+ * @param options Options for the retry function
211
+ */
212
+ declare function retryPromise<T>(fn: (signal?: AbortSignal) => Promise<T>, options?: RetryOptions): Promise<T>;
213
+ /**
214
+ * Returns a promise that resolves after the given number of milliseconds.
215
+ * @param ms The time to wait in milliseconds
216
+ */
217
+ declare function wait(ms: number): Promise<boolean>;
218
+
219
+ interface ParseTimeOptions {
220
+ /** Return value in seconds instead of milliseconds. */
221
+ unit?: "ms" | "s";
222
+ /** If true, returns the absolute Unix timestamp (Date.now() + result). */
223
+ fromNow?: boolean;
224
+ }
225
+ /**
226
+ * Calculates the age of a person based on their birthdate.
227
+ * @param birthdate The birthdate of the person
228
+ */
229
+ declare function getAge(birthdate: Date): number;
230
+ /**
231
+ * Parses shorthand strings (1h 30m) into milliseconds or seconds.
232
+ * @param str The string to parse
233
+ * @param options Parsing options
234
+ */
235
+ declare function parseTime(str: string | number, options?: ParseTimeOptions): number;
236
+
237
+ interface DebouncedFunction<T extends (...args: unknown[]) => unknown> {
238
+ (...args: Parameters<T>): void;
239
+ /** Cancels the debounced function. */
240
+ cancel: () => void;
241
+ }
242
+ /**
243
+ * Only executes after 'wait' ms have passed since the last call.
244
+ * @param fn The function to debounce
245
+ * @param wait The time to wait in milliseconds
246
+ * @param options Options for the debounce function
247
+ * @example
248
+ * const search = debounce((str) => console.log("Searching:", str), 500);
249
+ * // Even if called rapidly, it only logs once 500ms after the last call.
250
+ * search('a');
251
+ * search('ab');
252
+ * search('abc'); // Only 'abc' will be logged.
253
+ * // Cancel a pending execution
254
+ * search.cancel();
255
+ */
256
+ declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, wait: number, options?: {
257
+ /** Calls the function immediately on the leading edge */
258
+ immediate?: boolean;
259
+ }): DebouncedFunction<T>;
260
+ /**
261
+ * Limits how often a function can be executed.
262
+ * @param fn The function to throttle
263
+ * @param limit The time to wait in milliseconds
264
+ * @example
265
+ * const logScroll = throttle(() => console.log('Scroll position:', window.scrollY), 200);
266
+ * // Even if the browser fires 100 scroll events per second,
267
+ * // this function will only execute once every 200ms.
268
+ * window.addEventListener('scroll', logScroll);
269
+ */
270
+ declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, limit: number): (...args: Parameters<T>) => void;
271
+
272
+ interface MemoizedFunction<T extends (...args: any[]) => any> {
273
+ (...args: Parameters<T>): ReturnType<T>;
274
+ /** Clears the cache. */
275
+ clear: () => void;
276
+ }
277
+ /**
278
+ * Memoizes a function by caching its results based on the input arguments.
279
+ * A resolver function can be provided to customize the key generation.
280
+ * If no resolver is provided, the key will be generated by JSON stringify-ing the input arguments.
281
+ * @param fn The function to memoize
282
+ * @param resolver An optional resolver function to customize the key generation
283
+ * @example
284
+ * // 1. Basic usage
285
+ * const heavyCalc = memoize((n: number) => {
286
+ * console.log('Calculating...');
287
+ * return n * 2;
288
+ * });
289
+ * heavyCalc(5); // Logs 'Calculating...' and returns 10
290
+ * heavyCalc(5); // Returns 10 immediately from cache
291
+ * @example
292
+ * // 2. Using maxAge (TTL)
293
+ * const getStockPrice = memoize(fetchPrice, { maxAge: 60000 }); // 1 minute cache
294
+ * @example
295
+ * // 3. Using a custom resolver
296
+ * const getUser = memoize(
297
+ * (user, theme) => render(user, theme),
298
+ * { resolver: (user) => user.id } // Only cache based on ID, ignore theme
299
+ * );
300
+ * @example
301
+ * // 4. Manual cache clearing
302
+ * heavyCalc.clear();
303
+ */
304
+ declare function memoize<T extends (...args: any[]) => any>(fn: T, options?: {
305
+ /** Function to generate a cache key from the input arguments. */
306
+ resolver?: (...args: Parameters<T>) => string;
307
+ /** The time to wait in milliseconds before expiring a cache entry. */
308
+ maxAge?: number;
309
+ }): MemoizedFunction<T>;
310
+
311
+ interface FormatDurationOptions {
312
+ /** The reference timestamp to calculate from. Defaults to Date.now() */
313
+ since?: number | Date;
314
+ /** If true, returns null if the target time is in the past. */
315
+ nullIfPast?: boolean;
316
+ /** If true, omits the " ago" suffix for past dates. */
317
+ ignorePast?: boolean;
318
+ }
319
+ /**
320
+ * Formats a number as a currency string using international standards.
321
+ * @param num - The number to process
322
+ * @param options - Formatting options
323
+ * @example
324
+ * currency(1234.5); // "$1,234.50"
325
+ * currency(1234.5, 'EUR', 'de-DE'); // "1.234,50 €"
326
+ * currency(500, 'JPY'); // "¥500" (Yen has no decimals)
327
+ */
328
+ declare function formatCurrency(num: number, options?: {
329
+ /** The ISO currency code (e.g., 'USD', 'EUR', 'GBP'). */
330
+ currency?: string;
331
+ /** The BCP 47 language tag. */
332
+ locale?: Intl.LocalesArgument;
333
+ }): string;
334
+ /**
335
+ * Formats a number with thousands separators and optional decimal precision.
336
+ * @param num - The number to process
337
+ * @param options - Formatting options
338
+ * @example
339
+ * num(1000000); // "1,000,000" (en-US default)
340
+ * num(1000, { locale: 'de-DE' }); // "1.000"
341
+ * num(1234.567, { precision: 2 }); // "1,234.57"
342
+ */
343
+ declare function formatNumber(num: number, options?: {
344
+ /** The BCP 47 language tag. */
345
+ locale?: Intl.LocalesArgument;
346
+ precision?: number;
347
+ }): string;
348
+ declare function formatMemory(bytes: number, decimals?: number, units?: string[]): string;
349
+ /**
350
+ * Formats a number to an ordinal (e.g., 1st, 2nd, 3rd).
351
+ * @param num The number to process
352
+ * @param locale The BCP 47 language tag
353
+ */
354
+ declare function formatOrdinal(num: number | string, locale?: Intl.LocalesArgument): string;
355
+ /**
356
+ * Formats a number into a compact, human-readable string (e.g., 1.2k, 1M).
357
+ * @param num - The number to process
358
+ * @param locale - The BCP 47 language tag
359
+ */
360
+ declare function FormatNumberCompact(num: number, locale?: Intl.LocalesArgument): string;
361
+ /**
362
+ * Duration formatter.
363
+ *
364
+ * Available styles:
365
+ * - Digital (00:00)
366
+ * - HMS
367
+ * - YMDHMS.
368
+ * @param target The target time to calculate from
369
+ * @param style The output style to use
370
+ * @param options Formatting options
371
+ */
372
+ declare function formatDuration(target: number | Date, style?: "digital" | "hms" | "ymdhms", options?: FormatDurationOptions): string | null;
373
+ /**
374
+ * Formats a date or timestamp into a human-readable relative string (e.g., "3 days ago").
375
+ * @param date - The Date object or timestamp to compare
376
+ * @param locale - The BCP 47 language tag
377
+ */
378
+ declare function formatETA(date: Date | number, locale?: Intl.LocalesArgument): string;
379
+
380
+ interface ReadDirOptions {
381
+ /** Whether to scan subdirectories [default: true] */
382
+ recursive?: boolean;
383
+ }
384
+ /**
385
+ * Recursively (or shallowly) scans a directory and returns an array of relative file paths.
386
+ * @param path The path to the directory
387
+ * @param options Options for the readDir function
388
+ */
389
+ declare function readDir(path: string, options?: ReadDirOptions): string[];
390
+
391
+ /**
392
+ * Checks if a value is defined (not null or undefined).
393
+ * @param val The value to check
394
+ */
395
+ declare function isDefined<T>(val: T | undefined | null): val is T;
396
+ /**
397
+ * Checks if a value is an empty object, array, or string.
398
+ * @param val The value to check
399
+ */
400
+ declare function isEmpty(val: unknown): boolean;
401
+ /**
402
+ * Checks if a value is a plain object (not an array, null, or function).
403
+ * @param val The value to check
404
+ */
405
+ declare function isObject(val: unknown): val is Record<string, any>;
406
+ /**
407
+ * Checks if a value is a string.
408
+ * @param val The value to check
409
+ */
410
+ declare function isString(val: unknown): val is string;
411
+ /**
412
+ * Checks if a number is within a specified range.
413
+ * @param num The number to check
414
+ * @param min The minimum or maximum value of the range
415
+ * @param max The maximum value of the range (optional)
416
+ */
417
+ declare function isInRange(num: number, max: number): boolean;
418
+ declare function isInRange(num: number, min: number, max: number): boolean;
419
+ /**
420
+ * Checks if an array is sorted.
421
+ * @param arr The array to check
422
+ * @param comparator Optional comparator function
423
+ */
424
+ declare function isSortedArray<T>(arr: T[], comparator?: (a: T, b: T) => number): boolean;
425
+ /**
426
+ * Checks if a date is today.
427
+ * @param date The date to check
428
+ */
429
+ declare function isToday(date: number | Date): boolean;
430
+
431
+ /**
432
+ * Clamps a number within a specified range.
433
+ * @param num The number to check
434
+ * @param min The minimum or maximum value of the range
435
+ * @param max The maximum value of the range (optional)
436
+ */
437
+ declare function clampNumber(num: number, max: number): number;
438
+ declare function clampNumber(num: number, min: number, max: number): number;
439
+ /**
440
+ * Linearly interpolates between two values.
441
+ * @param start - The starting value (0%)
442
+ * @param end - The ending value (100%)
443
+ * @param t - The interpolation factor (0 to 1)
444
+ * @example
445
+ * lerpLinear(0, 100, 0.5); // 50
446
+ * lerpLinear(10, 20, 0.2); // 12
447
+ */
448
+ declare function lerp(start: number, end: number, t: number): number;
449
+ /**
450
+ * Calculates the interpolation factor (0-1) of a value between two points.
451
+ * @param start - The starting value (0%)
452
+ * @param end - The ending value (100%)
453
+ * @param value - The value to interpolate
454
+ * @example
455
+ * inverseLerp(0, 100, 50); // 0.5
456
+ */
457
+ declare function inverseLerp(start: number, end: number, value: number): number;
458
+ /**
459
+ * Converts milliseconds to seconds and rounds it to the nearest integer.
460
+ * @param num The number of milliseconds to convert
461
+ */
462
+ declare function msToSecs(num: number): number;
463
+ /**
464
+ * Converts seconds to milliseconds and rounds it to the nearest integer.
465
+ * @param num The number of seconds to convert
466
+ */
467
+ declare function secsToMs(num: number): number;
468
+ /**
469
+ * Calculates the percentage value between two numbers.
470
+ * @param a The numerator
471
+ * @param b The denominator
472
+ * @param round Whether to round the result to the nearest integer
473
+ * @example
474
+ * percent(50, 100) --> 50 // 50%
475
+ * percent(30, 40) --> 75 // 75%
476
+ */
477
+ declare function percent(a: number, b: number, round?: boolean): number;
478
+ /**
479
+ * Maps a value from one range to another.
480
+ * @param value - The value to map
481
+ * @param inMin - The minimum value of the input range
482
+ * @param inMax - The maximum value of the input range
483
+ * @param outMin - The minimum value of the output range
484
+ * @param outMax - The maximum value of the output range
485
+ * @example
486
+ * // Convert mouse X position (0-1920) to a volume level (0-1)
487
+ * const volume = remap(mouseX, 0, 1920, 0, 1);
488
+ */
489
+ declare function remap(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
490
+ /**
491
+ * Returns the sum of an array of numbers. Negative values subtract from the total.
492
+ * @param array The array to sum
493
+ * @param selector Function that selects the item's weight
494
+ * @param ignoreNaN If true, NaN values will not throw an error
495
+ */
496
+ declare function sum(array: number[], selector?: (item: unknown) => number): number;
497
+ /**
498
+ * Wraps a number into a modular range.
499
+ * @param num The value to wrap
500
+ * @param max The upper bound
501
+ * @example
502
+ * ```ts
503
+ * wrap(12, 10); // 2 (overflow)
504
+ * wrap(-1, 10); // 9 (max - 1)
505
+ * ```
506
+ */
507
+ declare function wrap(num: number, max: number): number;
508
+
509
+ /**
510
+ * Retrieves a nested property.
511
+ * @param obj The object to process
512
+ * @param path The path to retrieve (e.g., 'data.users[0].id')
513
+ * @param defaultValue The default value to return if the property does not exist
514
+ */
515
+ declare function getProp<T = unknown>(obj: Record<string, unknown>, path: string, defaultValue?: T): T;
516
+ /**
517
+ * Checks if a nested path exists within an object.
518
+ * @param obj The object to process
519
+ * @param path The path to check (e.g., 'data.users[0].id')
520
+ */
521
+ declare function hasProp(obj: Record<string, unknown>, path: string): boolean;
522
+ /**
523
+ * Sets a nested property value. Recursively creates missing objects/arrays along the path.
524
+ * @param obj The object to process
525
+ * @param path The path to set (e.g., 'data.users[0].id')
526
+ * @param value The value to inject
527
+ */
528
+ declare function setProp(obj: Record<string, unknown>, path: string, value: unknown): void;
529
+ /**
530
+ * Deep merges multiple objects.
531
+ * @param target - The base object to merge into
532
+ * @param sources - One or more objects to merge
533
+ */
534
+ declare function merge<T, S1>(target: T, s1: S1): T & S1;
535
+ declare function merge<T, S1, S2>(target: T, s1: S1, s2: S2): T & S1 & S2;
536
+ declare function merge<T, S1, S2, S3>(target: T, s1: S1, s2: S2, s3: S3): T & S1 & S2 & S3;
537
+ declare function merge(target: any, ...sources: any[]): unknown;
538
+ /**
539
+ * Creates an object composed of the picked object properties.
540
+ * @param obj The object to process
541
+ * @param keys The keys to pick from the object
542
+ */
543
+ declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
544
+ /**
545
+ * Creates an object composed of the omitted object properties.
546
+ * @param obj The object to process
547
+ * @param keys The keys to omit from the object
548
+ */
549
+ declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
550
+
551
+ type AlphaCasing = "lower" | "upper" | "mixed";
552
+ interface RndArrayOptions<T> {
553
+ /** Optional seed for RNG */
554
+ seed?: number;
555
+ /** Reroll if the result is equal to this value */
556
+ not?: ((item: T) => boolean) | (T | null | undefined);
557
+ /** Maximum number of times to reroll if `not` is specified [default: 10] */
558
+ maxRerolls?: number;
559
+ }
560
+ interface RndStrOptions {
561
+ /** Optional seed for RNG */
562
+ seed?: number;
563
+ /** Character casing mode */
564
+ casing?: AlphaCasing;
565
+ /** Custom character pool */
566
+ customChars?: string;
567
+ /** Characters to exclude from the pool */
568
+ exclude?: string | string[];
569
+ }
570
+ /**
571
+ * Returns true based on a percentage probability.
572
+ * @param percent A value between 0 and 1 [default: 0.5]
573
+ * @param seed Optional seed for RNG
574
+ */
575
+ declare function rndChance(percent?: number, seed?: number): boolean;
576
+ /**
577
+ * Returns a random item from the given array.
578
+ * @param array Array of items to choose from
579
+ * @param options Options for the choice function
580
+ */
581
+ declare function rndChoice<T>(array: T[], options?: RndArrayOptions<T>): T;
582
+ /**
583
+ * Returns a random item from the given array based on their corresponding weights.
584
+ * @param array Array of items to choose from
585
+ * @param predicate Predicate that selects the item's weight
586
+ * @param seed Optional seed for RNG
587
+ */
588
+ declare function weightedRnd<T>(array: T[], predicate: (item: T) => number, seed?: number): T;
589
+ /**
590
+ * Creates an O(1) sampler for weighted random selection.
591
+ * The probability of each item being picked is determined by the corresponding weight in the `weights` array.
592
+ * @param items Array of items to choose from
593
+ * @param predicate Predicate that selects the item's weight
594
+ * @param seed Optional seed for RNG
595
+ */
596
+ declare function createSampler<T>(items: T[], predicate: (item: T) => number, seed?: number): {
597
+ /**
598
+ * Returns a random item from the given array in O(1) time
599
+ * @param seed Optional seed for RNG
600
+ */
601
+ pick: (seed?: number) => T | undefined;
602
+ };
603
+ /**
604
+ * Creates a deterministic pseudo-random number generator (PRNG) using the Mulberry32 algorithm.
605
+ * @param seed An integer seed value
606
+ * @example
607
+ * const rng = prng(123);
608
+ * const val1 = rng(); // Always the same for seed 123
609
+ */
610
+ declare function prng(seed: number): () => number;
611
+ /**
612
+ * Generates a random float between the given minimum and maximum values.
613
+ * @param min The minimum value (inclusive) for the random float
614
+ * @param max The maximum value (inclusive) for the random float
615
+ * @param seed Optional seed for RNG
616
+ */
617
+ declare function rndFloat(min: number, max: number, seed?: number): number;
618
+ /**
619
+ * Returns a random index from the given array.
620
+ * @param array The array to generate an index for
621
+ * @param options Options for the index function
622
+ */
623
+ declare function rndIndex<T>(array: T[], options?: RndArrayOptions<number>): number;
624
+ /**
625
+ * Generates a random integer between the given minimum and maximum values.
626
+ * @param min The minimum value (inclusive) for the random integer
627
+ * @param max The maximum value (inclusive) for the random integer
628
+ * @param seed Optional seed for RNG
629
+ */
630
+ declare function rndInt(min: number, max: number, seed?: number): number;
631
+ /**
632
+ * Generates a random string of the given length using the specified character pool.
633
+ * @param len The length of the random string
634
+ * @param mode The character pool to use
635
+ * @param options Options for the rndStr function
636
+ */
637
+ declare function rndString(len: number, mode: "number" | "alpha" | "alphanumeric" | "custom", options?: RndStrOptions): string;
638
+
639
+ /**
640
+ * Escapes regex characters in the given string.
641
+ * @param str The string to process
642
+ */
643
+ declare function escapeRegex(str: string): string;
644
+ /**
645
+ * Retrieves a substring following a specific flag.
646
+ * @param str The string to process
647
+ * @param flag A string or regex to look for
648
+ */
649
+ declare function getFlag(str: string, flag: string | RegExp, length?: number): string | null;
650
+ /**
651
+ * Checks if a string contains a specific flag.
652
+ * @param str The string to process
653
+ * @param flag A string or regex to look for
654
+ */
655
+ declare function hasFlag(str: string, flag: string | RegExp): boolean;
656
+ /**
657
+ * Returns the singular or plural form based on the given count.
658
+ * @param count The amount to compare against 1
659
+ * @param singular The word to use when count is exactly 1
660
+ * @param plural The word to use otherwise [default: `${singular}s`]
661
+ */
662
+ declare function pluralize(count: number, singular: string, plural?: string): string;
663
+ /**
664
+ * Formats a string to Title Case, optionally keeping acronyms and skipping minor words (the, and, of, etc.).
665
+ * @param str The string to process
666
+ * @param smart If true, will keep acronyms and skip minor words [default: true]
667
+ */
668
+ declare function toTitleCase(str: string, smart?: boolean): string;
669
+
670
+ export { type AlphaCasing, type AnyFunc, Cache, type DebouncedFunction, type DeepPartial, type FormatDurationOptions, FormatNumberCompact, Loop, type LoopEvents, type MemoizedFunction, type ParseTimeOptions, Pipe, type ReadDirOptions, type RetryOptions, type RndArrayOptions, type RndStrOptions, type SequentialMapContext, Storage, type TypedEmitter, chunk, chunkAdj, clampNumber, cluster, compactArray, createSampler, debounce, escapeRegex, forceArray, formatCurrency, formatDuration, formatETA, formatMemory, formatNumber, formatOrdinal, getAge, getFlag, getProp, hasFlag, hasProp, inverseLerp, isDefined, isEmpty, isInRange, isObject, isSortedArray, isString, isToday, lerp, memoize, merge, msToSecs, omit, parseTime, percent, pick, pluralize, prng, readDir, remap, retryPromise, rndChance, rndChoice, rndFloat, rndIndex, rndInt, rndString, searchSorted, secsToMs, seqMap, setProp, shuffle, sortBy, sum, throttle, toTitleCase, unique, wait, weightedRnd, wrap };