@ts-utilities/core 1.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,1288 @@
1
+ //#region src/functions/deepmerge.d.ts
2
+ type TAllKeys<T> = T extends any ? keyof T : never;
3
+ type TIndexValue<T, K$1 extends PropertyKey, D = never> = T extends any ? K$1 extends keyof T ? T[K$1] : D : never;
4
+ type TPartialKeys<T, K$1 extends keyof T> = Omit<T, K$1> & Partial<Pick<T, K$1>> extends infer O ? { [P in keyof O]: O[P] } : never;
5
+ type TFunction = (...a: any[]) => any;
6
+ type TPrimitives = string | number | boolean | bigint | symbol | Date | TFunction;
7
+ type DeepMergeOptions = {
8
+ arrayMerge?: 'replace' | 'concat' | 'merge' | ((target: any[], source: any[]) => any[]);
9
+ clone?: boolean;
10
+ customMerge?: (key: string | symbol, targetValue: any, sourceValue: any) => any;
11
+ functionMerge?: 'replace' | 'compose';
12
+ maxDepth?: number;
13
+ };
14
+ type TMerged<T> = [T] extends [Array<any>] ? { [K in keyof T]: TMerged<T[K]> } : [T] extends [TPrimitives] ? T : [T] extends [object] ? TPartialKeys<{ [K in TAllKeys<T>]: TMerged<TIndexValue<T, K>> }, never> : T;
15
+ /**
16
+ * Deeply merges multiple objects, with later sources taking precedence.
17
+ * Handles nested objects, arrays, and special object types with circular reference detection.
18
+ *
19
+ * Features:
20
+ * - Deep merging of nested objects
21
+ * - Configurable array merging strategies
22
+ * - Circular reference detection and handling
23
+ * - Support for symbols and special objects (Date, RegExp, etc.)
24
+ * - Type-safe with improved generics
25
+ * - Optional cloning to avoid mutation
26
+ * - Custom merge functions for specific keys
27
+ *
28
+ * @template T - The target object type
29
+ * @param target - The target object to merge into
30
+ * @param sources - Source objects to merge from (can have additional properties)
31
+ * @param options - Configuration options
32
+ * @param options.clone - Whether to clone the target (default: true)
33
+ * @param options.customMerge - Custom merge function for specific keys
34
+ * @param options.arrayMerge - How to merge arrays: 'replace' (default), 'concat', or 'merge'
35
+ * @param options.functionMerge - How to merge functions: 'replace' (default) or 'compose'
36
+ * @param options.maxDepth - Maximum recursion depth (default: 100)
37
+ * @returns The merged object with proper typing
38
+ *
39
+ * @example
40
+ * // Basic shallow merge
41
+ * deepmerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
42
+ *
43
+ * @example
44
+ * // Deep merge of nested objects
45
+ * deepmerge({ user: { name: 'John' } }, { user: { age: 30 } })
46
+ * // { user: { name: 'John', age: 30 } }
47
+ *
48
+ * @example
49
+ * // Array concatenation
50
+ * deepmerge({ tags: ['react'] }, { tags: ['typescript'] }, { arrayMerge: 'concat' })
51
+ * // { tags: ['react', 'typescript'] }
52
+ *
53
+ * @example
54
+ * // Array replacement (default)
55
+ * deepmerge({ items: [1, 2] }, { items: [3, 4] })
56
+ * // { items: [3, 4] }
57
+ *
58
+ * @example
59
+ * // Custom array merging
60
+ * deepmerge(
61
+ * { scores: [85, 90] },
62
+ * { scores: [95] },
63
+ * { arrayMerge: (target, source) => [...target, ...source] }
64
+ * )
65
+ * // { scores: [85, 90, 95] }
66
+ *
67
+ * @example
68
+ * // Configuration merging
69
+ * const defaultConfig = { theme: 'light', features: { darkMode: false } };
70
+ * const userConfig = { theme: 'dark', features: { darkMode: true, animations: true } };
71
+ * deepmerge(defaultConfig, userConfig);
72
+ * // { theme: 'dark', features: { darkMode: true, animations: true } }
73
+ *
74
+ * @example
75
+ * // State updates in reducers
76
+ * const initialState = { user: { profile: { name: '' } }, settings: {} };
77
+ * const action = { user: { profile: { name: 'Alice' } }, settings: { theme: 'dark' } };
78
+ * const newState = deepmerge(initialState, action);
79
+ *
80
+ * @example
81
+ * // Merging API responses
82
+ * const cachedData = { posts: [{ id: 1, title: 'Old' }] };
83
+ * const freshData = { posts: [{ id: 1, title: 'Updated', author: 'Bob' }] };
84
+ * deepmerge(cachedData, freshData);
85
+ * // { posts: [{ id: 1, title: 'Updated', author: 'Bob' }] }
86
+ *
87
+ * @example
88
+ * // Function composition
89
+ * const log1 = () => console.log('first');
90
+ * const log2 = () => console.log('second');
91
+ * const composed = deepmerge(log1, log2, { functionMerge: 'compose' });
92
+ * composed(); // logs 'first' then 'second'
93
+ */
94
+ declare function deepmerge<T extends Record<string, any>, S$1 extends Record<string, any>[]>(target: T, ...sources: S$1): TMerged<T | S$1[number]>;
95
+ declare function deepmerge<T extends Record<string, any>, S$1 extends Record<string, any>[]>(target: T, sources: S$1, options?: DeepMergeOptions): TMerged<T | S$1[number]>;
96
+ //#endregion
97
+ //#region src/functions/hydrate.d.ts
98
+ type Hydrate<T> = T extends null ? undefined : T extends (infer U)[] ? Hydrate<U>[] : T extends object ? { [K in keyof T]: Hydrate<T[K]> } : T;
99
+ /**
100
+ * Converts all `null` values to `undefined` in the data structure recursively.
101
+ *
102
+ * @param data - Any input data (object, array, primitive)
103
+ * @returns Same type as input, but with all nulls replaced by undefined
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * // Basic object hydration
108
+ * hydrate({ name: null, age: 25 }) // { name: undefined, age: 25 }
109
+ *
110
+ * // Nested object hydration
111
+ * hydrate({
112
+ * user: { email: null, profile: { avatar: null } },
113
+ * settings: { theme: 'dark' }
114
+ * })
115
+ * // { user: { email: undefined, profile: { avatar: undefined } }, settings: { theme: 'dark' } }
116
+ *
117
+ * // Array hydration
118
+ * hydrate([null, 'hello', null, 42]) // [undefined, 'hello', undefined, 42]
119
+ *
120
+ * // Mixed data structures
121
+ * hydrate({
122
+ * posts: [null, { title: 'Hello', content: null }],
123
+ * metadata: { published: null, tags: ['react', null] }
124
+ * })
125
+ * ```
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * // API response normalization
130
+ * const apiResponse = await fetch('/api/user');
131
+ * const rawData = await apiResponse.json(); // May contain null values
132
+ * const normalizedData = hydrate(rawData); // Convert nulls to undefined
133
+ *
134
+ * // Database result processing
135
+ * const dbResult = query('SELECT * FROM users'); // Some fields may be NULL
136
+ * const cleanData = hydrate(dbResult); // Normalize for consistent handling
137
+ *
138
+ * // Form data sanitization
139
+ * const formData = getFormValues(); // May have null values from empty fields
140
+ * const sanitizedData = hydrate(formData); // Prepare for validation/state
141
+ * ```
142
+ */
143
+ declare function hydrate<T>(data: T): Hydrate<T>;
144
+ //#endregion
145
+ //#region src/functions/object.d.ts
146
+ /**
147
+ * Type representing a path split into segments
148
+ * @template S - The original path string type
149
+ */
150
+ type SplitPath<S$1 extends string> = S$1 extends `${infer First}.${infer Rest}` ? [First, ...SplitPath<Rest>] : [S$1];
151
+ /**
152
+ * Recursive type to resolve nested object types based on path
153
+ * @template T - Current object type
154
+ * @template K - Array of path segments
155
+ */
156
+ type GetValue<T, K$1 extends Array<string | number>> = K$1 extends [infer First, ...infer Rest] ? First extends keyof T ? GetValue<T[First], Rest extends Array<string | number> ? Rest : []> : First extends `${number}` ? T extends any[] ? GetValue<T[number], Rest extends Array<string | number> ? Rest : []> : undefined : undefined : T;
157
+ /**
158
+ * Get a nested value from an object using array path segments
159
+ * @template T - Object type
160
+ * @template K - Path segments array type
161
+ * @template D - Default value type
162
+ * @param obj - Source object
163
+ * @param path - Array of path segments
164
+ * @param defaultValue - Fallback value if path not found
165
+ * @returns Value at path or default value
166
+ *
167
+ * @example
168
+ * getObjectValue({a: [{b: 1}]}, ['a', 0, 'b']) // 1
169
+ */
170
+ declare function getObjectValue<T, K$1 extends Array<string | number>, D>(obj: T, path: K$1, defaultValue: D): Exclude<GetValue<T, K$1>, undefined> | D;
171
+ /**
172
+ * Get a nested value from an object using array path segments
173
+ * @template T - Object type
174
+ * @template K - Path segments array type
175
+ * @param obj - Source object
176
+ * @param path - Array of path segments
177
+ * @returns Value at path or undefined
178
+ *
179
+ * @example
180
+ * getObjectValue({a: [{b: 1}]}, ['a', 0, 'b']) // 1
181
+ */
182
+ declare function getObjectValue<T, K$1 extends Array<string | number>>(obj: T, path: K$1): GetValue<T, K$1> | undefined;
183
+ /**
184
+ * Get a nested value from an object using dot notation path
185
+ * @template T - Object type
186
+ * @template S - Path string literal type
187
+ * @template D - Default value type
188
+ * @param obj - Source object
189
+ * @param path - Dot-separated path string
190
+ * @param defaultValue - Fallback value if path not found
191
+ * @returns Value at path or default value
192
+ *
193
+ * @example
194
+ * getObjectValue({a: [{b: 1}]}, 'a.0.b', 2) // 1
195
+ */
196
+ declare function getObjectValue<T, S$1 extends string, D>(obj: T, path: S$1, defaultValue: D): Exclude<GetValue<T, SplitPath<S$1>>, undefined> | D;
197
+ /**
198
+ * Get a nested value from an object using dot notation path
199
+ * @template T - Object type
200
+ * @template S - Path string literal type
201
+ * @param obj - Source object
202
+ * @param path - Dot-separated path string
203
+ * @returns Value at path or undefined
204
+ *
205
+ * @example
206
+ * getObjectValue({a: [{b: 1}]}, 'a.0.b') // 1
207
+ */
208
+ declare function getObjectValue<T, S$1 extends string>(obj: T, path: S$1): GetValue<T, SplitPath<S$1>> | undefined;
209
+ /**
210
+ * Extend an object or function with additional properties while
211
+ * preserving the original type information.
212
+ *
213
+ * Works with both plain objects and callable functions since
214
+ * functions in JavaScript are objects too. Also handles nullable types.
215
+ *
216
+ * @template T The base object or function type (can be null/undefined)
217
+ * @template P The additional properties type
218
+ *
219
+ * @param base - The object or function to extend (can be null/undefined)
220
+ * @param props - An object containing properties to attach
221
+ *
222
+ * @returns The same object/function, augmented with the given properties, or the original value if null/undefined
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * // Extend a plain object
227
+ * const config = extendProps({ apiUrl: '/api' }, { timeout: 5000 });
228
+ * // config has both apiUrl and timeout properties
229
+ *
230
+ * // Extend a function with metadata
231
+ * const fetchData = (url: string) => fetch(url).then(r => r.json());
232
+ * const enhancedFetch = extendProps(fetchData, {
233
+ * description: 'Data fetching utility',
234
+ * version: '1.0'
235
+ * });
236
+ * // enhancedFetch is callable and has description/version properties
237
+ *
238
+ * // Create plugin system
239
+ * const basePlugin = { name: 'base', enabled: true };
240
+ * const authPlugin = extendProps(basePlugin, {
241
+ * authenticate: (token: string) => validateToken(token)
242
+ * });
243
+ *
244
+ * // Build configuration objects
245
+ * const defaultSettings = { theme: 'light', lang: 'en' };
246
+ * const userSettings = extendProps(defaultSettings, {
247
+ * theme: 'dark',
248
+ * notifications: true
249
+ * });
250
+ *
251
+ * // Handle nullable types (e.g., Supabase Session | null)
252
+ * const session: Session | null = getSession();
253
+ * const extendedSession = extendProps(session, { customProp: 'value' });
254
+ * // extendedSession is (Session & { customProp: string }) | null
255
+ * ```
256
+ */
257
+ declare function extendProps<T, P$1 extends object>(base: T, props: P$1): T extends null | undefined ? T : T & P$1;
258
+ //#endregion
259
+ //#region src/functions/poll.d.ts
260
+ /**
261
+ * Repeatedly polls an async `cond` function UNTIL it returns a TRUTHY value,
262
+ * or until the operation times out or is aborted.
263
+ *
264
+ * Designed for waiting on async jobs, external state, or delayed availability.
265
+ *
266
+ * @template T The type of the successful result.
267
+ *
268
+ * @param cond
269
+ * A function returning a Promise that resolves to:
270
+ * - a truthy value `T` → stop polling and return it
271
+ * - falsy/null/undefined → continue polling
272
+ *
273
+ * @param options
274
+ * Configuration options:
275
+ * - `interval` (number) — Time between polls in ms (default: 5000 ms)
276
+ * - `timeout` (number) — Max total duration before failing (default: 5 min)
277
+ * - `jitter` (boolean) — Add small random offset (±10%) to intervals to avoid sync bursts (default: true)
278
+ * - `signal` (AbortSignal) — Optional abort signal to cancel polling
279
+ *
280
+ * @returns
281
+ * Resolves with the truthy value `T` when successful.
282
+ * Throws `AbortError` if aborted
283
+ *
284
+ * @example
285
+ * ```ts
286
+ * // Poll for job completion
287
+ * const job = await poll(async () => {
288
+ * const status = await getJobStatus();
289
+ * return status === 'done' ? status : null;
290
+ * }, { interval: 3000, timeout: 60000 });
291
+ * ```
292
+ *
293
+ * @example
294
+ * ```ts
295
+ * // Wait for API endpoint to be ready
296
+ * const apiReady = await poll(async () => {
297
+ * try {
298
+ * await fetch('/api/health');
299
+ * return true;
300
+ * } catch {
301
+ * return null;
302
+ * }
303
+ * }, { interval: 1000, timeout: 30000 });
304
+ * ```
305
+ *
306
+ * @example
307
+ * ```ts
308
+ * // Poll with abort signal for cancellation
309
+ * const controller = new AbortController();
310
+ * setTimeout(() => controller.abort(), 10000); // Cancel after 10s
311
+ *
312
+ * try {
313
+ * const result = await poll(
314
+ * () => checkExternalService(),
315
+ * { interval: 2000, signal: controller.signal }
316
+ * );
317
+ * } catch (err) {
318
+ * if (err.name === 'AbortError') {
319
+ * console.log('Polling was cancelled');
320
+ * }
321
+ * }
322
+ * ```
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * // Poll for user action completion
327
+ * const userConfirmed = await poll(async () => {
328
+ * const confirmations = await getPendingConfirmations();
329
+ * return confirmations.length > 0 ? confirmations[0] : null;
330
+ * }, { interval: 5000, timeout: 300000 }); // 5 min timeout
331
+ * ```
332
+ */
333
+ declare function poll<T>(cond: () => Promise<T | null | false | undefined>, {
334
+ interval,
335
+ timeout,
336
+ jitter,
337
+ signal
338
+ }?: Partial<{
339
+ interval: number;
340
+ timeout: number;
341
+ signal: AbortSignal;
342
+ jitter: boolean;
343
+ }>): Promise<T>;
344
+ //#endregion
345
+ //#region src/functions/schedule.d.ts
346
+ /**
347
+ * A task function that can be synchronous or asynchronous.
348
+ */
349
+ type Task = () => Promise<void> | void;
350
+ /**
351
+ * Options for configuring the schedule function.
352
+ */
353
+ interface ScheduleOpts {
354
+ /** Number of retry attempts on failure. Defaults to 0. */
355
+ retry?: number;
356
+ /** Delay in milliseconds between retries. Defaults to 0. */
357
+ delay?: number;
358
+ /** Maximum time in milliseconds to wait for the task to complete. */
359
+ timeout?: number;
360
+ }
361
+ /**
362
+ * Runs a function asynchronously in the background without blocking the main thread.
363
+ *
364
+ * Executes the task immediately using setTimeout, with optional retry logic on failure.
365
+ * Useful for non-critical operations like analytics, logging, or background processing.
366
+ * Logs execution time and retry attempts to the console.
367
+ *
368
+ * @param task - The function to execute asynchronously
369
+ * @param options - Configuration options for retries and timing
370
+ *
371
+ * @example
372
+ * ```ts
373
+ * // Simple background task
374
+ * schedule(() => {
375
+ * console.log('Background work done');
376
+ * });
377
+ *
378
+ * // Task with retry on failure
379
+ * schedule(
380
+ * () => sendAnalytics(),
381
+ * { retry: 3, delay: 1000 }
382
+ * );
383
+ * ```
384
+ */
385
+ declare function schedule(task: Task, options?: ScheduleOpts): void;
386
+ //#endregion
387
+ //#region src/functions/shield.d.ts
388
+ /**
389
+ * A helper to run sync or async operations safely without try/catch.
390
+ *
391
+ * Returns a tuple `[error, data]`:
392
+ * - `error`: the thrown error (if any), otherwise `null`
393
+ * - `data`: the resolved value (if successful), otherwise `null`
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * // Synchronous error handling
398
+ * const [err, value] = shield(() => {
399
+ * if (Math.random() > 0.5) throw new Error('Random failure');
400
+ * return 'success';
401
+ * });
402
+ * if (err) {
403
+ * console.error('Operation failed:', err);
404
+ * } else {
405
+ * console.log('Result:', value);
406
+ * }
407
+ *
408
+ * // Asynchronous error handling
409
+ * const [asyncErr, result] = await shield(async () => {
410
+ * const response = await fetch('/api/data');
411
+ * if (!response.ok) throw new Error('API error');
412
+ * return response.json();
413
+ * });
414
+ * if (asyncErr) {
415
+ * console.error('API call failed:', asyncErr);
416
+ * } else {
417
+ * processData(result);
418
+ * }
419
+ *
420
+ * // API calls with fallbacks
421
+ * const [fetchErr, data] = await shield(fetchUserData(userId));
422
+ * const userData = fetchErr ? getCachedUserData(userId) : data;
423
+ *
424
+ * // File operations
425
+ * const [fileErr, content] = shield(() => readFileSync('config.json'));
426
+ * if (fileErr) {
427
+ * console.warn('Could not read config, using defaults');
428
+ * return defaultConfig;
429
+ * }
430
+ * ```
431
+ *
432
+ * @example
433
+ * ```ts
434
+ * // In async functions
435
+ * async function safeApiCall() {
436
+ * const [err, result] = await shield(callExternalAPI());
437
+ * if (err) {
438
+ * await logError(err);
439
+ * return null;
440
+ * }
441
+ * return result;
442
+ * }
443
+ *
444
+ * // In event handlers
445
+ * function handleSubmit(formData) {
446
+ * const [validationErr, validatedData] = shield(() => validateForm(formData));
447
+ * if (validationErr) {
448
+ * showValidationError(validationErr);
449
+ * return;
450
+ * }
451
+ * submitData(validatedData);
452
+ * }
453
+ * ```
454
+ */
455
+ declare function shield<T, E = Error>(operation: Promise<T>): Promise<[E | null, T | null]>;
456
+ declare function shield<T, E = Error>(operation: () => T): [E | null, T | null];
457
+ //#endregion
458
+ //#region src/functions/utils-core.d.ts
459
+ /**
460
+ * Converts various case styles (camelCase, PascalCase, kebab-case, snake_case) into readable normal case.
461
+ *
462
+ * Transforms technical naming conventions into human-readable titles by:
463
+ * - Adding spaces between words
464
+ * - Capitalizing the first letter of each word
465
+ * - Handling common separators (-, _, camelCase boundaries)
466
+ *
467
+ * @param inputString - The string to convert (supports camelCase, PascalCase, kebab-case, snake_case).
468
+ * @returns The converted string in normal case (title case).
469
+ *
470
+ * @example
471
+ * ```ts
472
+ * convertToNormalCase('camelCase') // 'Camel Case'
473
+ * convertToNormalCase('kebab-case') // 'Kebab Case'
474
+ * convertToNormalCase('snake_case') // 'Snake Case'
475
+ * convertToNormalCase('PascalCase') // 'Pascal Case'
476
+ * ```
477
+ */
478
+ declare function convertToNormalCase(inputString: string): string;
479
+ /**
480
+ * Converts a string to a URL-friendly slug by trimming, converting to lowercase,
481
+ * replacing diacritics, removing invalid characters, and replacing spaces with hyphens.
482
+ * @param {string} [str] - The input string to convert.
483
+ * @returns {string} The generated slug.
484
+ * @example
485
+ * convertToSlug("Hello World!"); // "hello-world"
486
+ * convertToSlug("Déjà Vu"); // "deja-vu"
487
+ */
488
+ declare const convertToSlug: (str: string) => string;
489
+ /**
490
+ * Pauses execution for the specified time.
491
+ *
492
+ * `signal` allows cancelling the sleep via AbortSignal.
493
+ *
494
+ * @param time - Time in milliseconds to sleep (default is 1000ms)
495
+ * @param signal - Optional AbortSignal to cancel the sleep early
496
+ * @returns - A Promise that resolves after the specified time or when aborted
497
+ */
498
+ declare const sleep: (time?: number, signal?: AbortSignal) => Promise<void>;
499
+ type DebouncedFunction<F$1 extends (...args: any[]) => any> = {
500
+ (...args: Parameters<F$1>): ReturnType<F$1> | undefined;
501
+ readonly isPending: boolean;
502
+ };
503
+ /**
504
+ * Creates a debounced function that delays invoking the provided function until
505
+ * after the specified `wait` time has elapsed since the last invocation.
506
+ *
507
+ * If the `immediate` option is set to `true`, the function will be invoked immediately
508
+ * on the leading edge of the wait interval. Subsequent calls during the wait interval
509
+ * will reset the timer but not invoke the function until the interval elapses again.
510
+ *
511
+ * The returned function includes the `isPending` property to check if the debounce
512
+ * timer is currently active.
513
+ *
514
+ * @typeParam F - The type of the function to debounce.
515
+ *
516
+ * @param function_ - The function to debounce.
517
+ * @param wait - The number of milliseconds to delay (default is 100ms).
518
+ * @param options - An optional object with the following properties:
519
+ * - `immediate` (boolean): If `true`, invokes the function on the leading edge
520
+ * of the wait interval instead of the trailing edge.
521
+ *
522
+ * @returns A debounced version of the provided function, enhanced with the `isPending` property.
523
+ *
524
+ * @throws {TypeError} If the first parameter is not a function.
525
+ * @throws {RangeError} If the `wait` parameter is negative.
526
+ *
527
+ * @example
528
+ * ```ts
529
+ * // Basic debouncing
530
+ * const log = debounce((message: string) => console.log(message), 200);
531
+ * log('Hello'); // Logs "Hello" after 200ms if no other call is made.
532
+ * console.log(log.isPending); // true if the timer is active.
533
+ *
534
+ * // Immediate execution
535
+ * const save = debounce(() => saveToServer(), 500, { immediate: true });
536
+ * save(); // Executes immediately, then waits 500ms for subsequent calls
537
+ *
538
+ * // Check pending state
539
+ * const debouncedSearch = debounce(searchAPI, 300);
540
+ * debouncedSearch('query');
541
+ * if (debouncedSearch.isPending) {
542
+ * showLoadingIndicator();
543
+ * }
544
+ * ```
545
+ */
546
+ declare function debounce<F$1 extends (...args: any[]) => any>(function_: F$1, wait?: number, options?: {
547
+ immediate: boolean;
548
+ }): DebouncedFunction<F$1>;
549
+ type ThrottledFunction<F$1 extends (...args: any[]) => any> = {
550
+ (...args: Parameters<F$1>): ReturnType<F$1> | undefined;
551
+ readonly isPending: boolean;
552
+ };
553
+ /**
554
+ * Creates a throttled function that invokes the provided function at most once
555
+ * every `wait` milliseconds.
556
+ *
557
+ * If the `leading` option is set to `true`, the function will be invoked immediately
558
+ * on the leading edge of the throttle interval. If the `trailing` option is set to `true`,
559
+ * the function will also be invoked at the end of the throttle interval if additional
560
+ * calls were made during the interval.
561
+ *
562
+ * The returned function includes the `isPending` property to check if the throttle
563
+ * timer is currently active.
564
+ *
565
+ * @typeParam F - The type of the function to throttle.
566
+ *
567
+ * @param function_ - The function to throttle.
568
+ * @param wait - The number of milliseconds to wait between invocations (default is 100ms).
569
+ * @param options - An optional object with the following properties:
570
+ * - `leading` (boolean): If `true`, invokes the function on the leading edge of the interval.
571
+ * - `trailing` (boolean): If `true`, invokes the function on the trailing edge of the interval.
572
+ *
573
+ * @returns A throttled version of the provided function, enhanced with the `isPending` property.
574
+ *
575
+ * @throws {TypeError} If the first parameter is not a function.
576
+ * @throws {RangeError} If the `wait` parameter is negative.
577
+ *
578
+ * @example
579
+ * ```ts
580
+ * // Basic throttling (leading edge by default)
581
+ * const log = throttle((message: string) => console.log(message), 200);
582
+ * log('Hello'); // Logs "Hello" immediately
583
+ * log('World'); // Ignored for 200ms
584
+ * console.log(log.isPending); // true if within throttle window
585
+ *
586
+ * // Trailing edge only
587
+ * const trailingLog = throttle(() => console.log('trailing'), 200, {
588
+ * leading: false,
589
+ * trailing: true
590
+ * });
591
+ * trailingLog(); // No immediate execution
592
+ * // After 200ms: logs "trailing"
593
+ *
594
+ * // Both edges
595
+ * const bothLog = throttle(() => console.log('both'), 200, {
596
+ * leading: true,
597
+ * trailing: true
598
+ * });
599
+ * bothLog(); // Immediate execution
600
+ * // After 200ms: executes again if called during window
601
+ * ```
602
+ */
603
+ declare function throttle<F$1 extends (...args: any[]) => any>(function_: F$1, wait?: number, options?: {
604
+ leading?: boolean;
605
+ trailing?: boolean;
606
+ }): ThrottledFunction<F$1>;
607
+ /**
608
+ * Formats a string by replacing each '%s' placeholder with the corresponding argument.
609
+ *
610
+ * Mimics the basic behavior of C's printf for %s substitution. Supports both
611
+ * variadic arguments and array-based argument passing. Extra placeholders
612
+ * are left as-is, missing arguments result in empty strings.
613
+ *
614
+ * @param format - The format string containing '%s' placeholders.
615
+ * @param args - The values to substitute, either as separate arguments or a single array.
616
+ * @returns The formatted string with placeholders replaced by arguments.
617
+ *
618
+ * @example
619
+ * ```ts
620
+ * // Basic usage with separate arguments
621
+ * printf("%s love %s", "I", "Bangladesh") // "I love Bangladesh"
622
+ *
623
+ * // Using array of arguments
624
+ * printf("%s love %s", ["I", "Bangladesh"]) // "I love Bangladesh"
625
+ *
626
+ * // Extra placeholders remain unchanged
627
+ * printf("%s %s %s", "Hello", "World") // "Hello World %s"
628
+ *
629
+ * // Missing arguments become empty strings
630
+ * printf("%s and %s", "this") // "this and "
631
+ *
632
+ * // Multiple occurrences
633
+ * printf("%s %s %s", "repeat", "repeat", "repeat") // "repeat repeat repeat"
634
+ * ```
635
+ */
636
+ declare function printf(format: string, ...args: unknown[]): string;
637
+ /**
638
+ * Escapes a string for use in a regular expression.
639
+ *
640
+ * @param str - The string to escape
641
+ * @returns - The escaped string safe for use in RegExp constructor
642
+ *
643
+ * @example
644
+ * ```ts
645
+ * const escapedString = escapeRegExp('Hello, world!');
646
+ * // escapedString === 'Hello\\, world!'
647
+ *
648
+ * const regex = new RegExp(escapeRegExp(userInput));
649
+ * ```
650
+ */
651
+ declare function escapeRegExp(str: string): string;
652
+ /**
653
+ * Normalizes a string by:
654
+ * - Applying Unicode normalization (NFC)
655
+ * - Optionally removing diacritic marks (accents)
656
+ * - Optionally trimming leading/trailing non-alphanumeric characters
657
+ * - Optionally converting to lowercase
658
+ *
659
+ * @param str - The string to normalize
660
+ * @param options - Normalization options
661
+ * @param options.lowercase - Whether to convert the result to lowercase (default: true)
662
+ * @param options.removeAccents - Whether to remove diacritic marks like accents (default: true)
663
+ * @param options.removeNonAlphanumeric - Whether to trim non-alphanumeric characters from the edges (default: true)
664
+ * @returns The normalized string
665
+ *
666
+ * @example
667
+ * ```ts
668
+ * normalizeText('Café') // 'cafe'
669
+ * normalizeText(' Hello! ') // 'hello'
670
+ * normalizeText('José', { removeAccents: false }) // 'josé'
671
+ * ```
672
+ */
673
+ declare function normalizeText(str?: string | null, options?: {
674
+ lowercase?: boolean;
675
+ removeAccents?: boolean;
676
+ removeNonAlphanumeric?: boolean;
677
+ }): string;
678
+ //#endregion
679
+ //#region src/types/utilities.d.ts
680
+ /**
681
+ * Extracts the keys of an object type as a union type.
682
+ *
683
+ * @template T - The object type to extract keys from
684
+ * @returns A union of all keys in the object type
685
+ *
686
+ * @example
687
+ * ```ts
688
+ * type User = { name: string; age: number };
689
+ * type UserKeys = Keys<User>; // 'name' | 'age'
690
+ * ```
691
+ */
692
+ type Keys<T extends object> = keyof T;
693
+ /**
694
+ * Extracts the values of an object type as a union type.
695
+ *
696
+ * @template T - The object type to extract values from
697
+ * @returns A union of all values in the object type
698
+ *
699
+ * @example
700
+ * ```ts
701
+ * type User = { name: string; age: number };
702
+ * type UserValues = Values<User>; // string | number
703
+ * ```
704
+ */
705
+ type Values<T extends object> = T[keyof T];
706
+ /**
707
+ * Makes all properties of an object type optional recursively.
708
+ *
709
+ * This type traverses through nested objects and arrays, making all properties optional.
710
+ * Functions and primitives are left unchanged.
711
+ *
712
+ * @template T - The type to make deeply partial
713
+ * @returns A type with all properties optional recursively
714
+ *
715
+ * @example
716
+ * ```ts
717
+ * type Config = {
718
+ * server: { host: string; port: number };
719
+ * features: string[];
720
+ * };
721
+ *
722
+ * type PartialConfig = DeepPartial<Config>;
723
+ * // {
724
+ * // server?: { host?: string; port?: number };
725
+ * // features?: string[];
726
+ * // }
727
+ * ```
728
+ */
729
+ type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
730
+ /**
731
+ * Makes only specified properties of an object type optional.
732
+ *
733
+ * @template T - The base object type
734
+ * @template K - The keys to make optional
735
+ * @returns An object type with specified properties optional
736
+ *
737
+ * @example
738
+ * ```ts
739
+ * type User = { name: string; age: number; email: string };
740
+ * type PartialUser = SelectivePartial<User, 'age' | 'email'>;
741
+ * // { name: string; age?: number; email?: string }
742
+ * ```
743
+ */
744
+ type SelectivePartial<T, K$1 extends keyof T> = Omit<T, K$1> & Partial<Pick<T, K$1>>;
745
+ /**
746
+ * Makes all properties of an object type required recursively.
747
+ *
748
+ * This type traverses through nested objects and arrays, making all properties required.
749
+ * Functions and primitives are left unchanged.
750
+ *
751
+ * @template T - The type to make deeply required
752
+ * @returns A type with all properties required recursively
753
+ *
754
+ * @example
755
+ * ```ts
756
+ * type PartialConfig = {
757
+ * server?: { host?: string; port?: number };
758
+ * };
759
+ *
760
+ * type RequiredConfig = DeepRequired<PartialConfig>;
761
+ * // {
762
+ * // server: { host: string; port: number };
763
+ * // }
764
+ * ```
765
+ */
766
+ type DeepRequired<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepRequired<U>> : T extends object ? { [K in keyof T]-?: DeepRequired<T[K]> } : T;
767
+ /**
768
+ * Makes only specified properties of an object type required.
769
+ *
770
+ * @template T - The base object type
771
+ * @template K - The keys to make required
772
+ * @returns An object type with specified properties required
773
+ *
774
+ * @example
775
+ * ```ts
776
+ * type PartialUser = { name?: string; age?: number; email?: string };
777
+ * type RequiredUser = SelectiveRequired<PartialUser, 'name'>;
778
+ * // { name: string; age?: number; email?: string }
779
+ * ```
780
+ */
781
+ type SelectiveRequired<T, K$1 extends keyof T> = Omit<T, K$1> & Required<Pick<T, K$1>>;
782
+ /**
783
+ * Creates a type where all properties are never (useful for excluding types).
784
+ *
785
+ * This can be used to create mutually exclusive types or to exclude certain properties.
786
+ *
787
+ * @template T - The object type to transform
788
+ * @returns An object type with all properties set to never
789
+ *
790
+ * @example
791
+ * ```ts
792
+ * type User = { name: string; age: number };
793
+ * type ExcludedUser = Never<User>; // { name: never; age: never }
794
+ * ```
795
+ */
796
+ type Never<T> = { [K in keyof T]: never };
797
+ /**
798
+ * Makes all properties of an object type nullable recursively.
799
+ *
800
+ * @template T - The type to make nullable
801
+ * @returns A type where all properties can be null
802
+ *
803
+ * @example
804
+ * ```ts
805
+ * type User = { name: string; profile: { age: number } };
806
+ * type NullableUser = Nullable<User>;
807
+ * // { name: string | null; profile: { age: number | null } | null }
808
+ * ```
809
+ */
810
+ type Nullable<T> = T extends object ? { [P in keyof T]: Nullable<T[P]> } : T | null;
811
+ /**
812
+ * Makes all properties of an object type optional (undefined) recursively.
813
+ *
814
+ * @template T - The type to make optional
815
+ * @returns A type where all properties can be undefined
816
+ *
817
+ * @example
818
+ * ```ts
819
+ * type User = { name: string; profile: { age: number } };
820
+ * type OptionalUser = Optional<User>;
821
+ * // { name: string | undefined; profile: { age: number | undefined } | undefined }
822
+ * ```
823
+ */
824
+ type Optional<T> = T extends object ? { [P in keyof T]: Optional<T[P]> } : T | undefined;
825
+ /**
826
+ * Makes all properties of an object type nullish (null or undefined) recursively.
827
+ *
828
+ * @template T - The type to make nullish
829
+ * @returns A type where all properties can be null or undefined
830
+ *
831
+ * @example
832
+ * ```ts
833
+ * type User = { name: string; profile: { age: number } };
834
+ * type NullishUser = Nullish<User>;
835
+ * // { name: string | null | undefined; profile: { age: number | null | undefined } | null | undefined }
836
+ * ```
837
+ */
838
+ type Nullish<T> = T extends object ? { [P in keyof T]: Nullish<T[P]> } : T | null | undefined;
839
+ /**
840
+ * Makes all properties of an object type optional and nullish recursively.
841
+ *
842
+ * This combines optional properties with nullish values.
843
+ *
844
+ * @template T - The type to make maybe
845
+ * @returns A type where all properties are optional and can be null or undefined
846
+ *
847
+ * @example
848
+ * ```ts
849
+ * type User = { name: string; profile: { age: number } };
850
+ * type MaybeUser = Maybe<User>;
851
+ * // { name?: string | null | undefined; profile?: { age?: number | null | undefined } | null | undefined }
852
+ * ```
853
+ */
854
+ type Maybe<T> = T extends object ? { [P in keyof T]?: Nullish<T[P]> } : T | null | undefined;
855
+ /**
856
+ * Makes all properties of an object type readonly recursively.
857
+ *
858
+ * This type traverses through nested objects and arrays, making all properties readonly.
859
+ * Functions and primitives are left unchanged.
860
+ *
861
+ * @template T - The type to make deeply readonly
862
+ * @returns A type with all properties readonly recursively
863
+ *
864
+ * @example
865
+ * ```ts
866
+ * type Config = {
867
+ * server: { host: string; port: number };
868
+ * features: string[];
869
+ * };
870
+ *
871
+ * type ReadonlyConfig = DeepReadonly<Config>;
872
+ * // {
873
+ * // readonly server: { readonly host: string; readonly port: number };
874
+ * // readonly features: readonly string[];
875
+ * // }
876
+ * ```
877
+ */
878
+ type DeepReadonly<T> = T extends Function ? T : T extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
879
+ /**
880
+ * Removes readonly modifier from all properties of an object type recursively.
881
+ *
882
+ * @template T - The readonly type to make mutable
883
+ * @returns A type with all readonly modifiers removed
884
+ *
885
+ * @example
886
+ * ```ts
887
+ * type ReadonlyUser = { readonly name: string; readonly profile: { readonly age: number } };
888
+ * type MutableUser = Mutable<ReadonlyUser>;
889
+ * // { name: string; profile: { age: number } }
890
+ * ```
891
+ */
892
+ type Mutable<T> = { -readonly [P in keyof T]: T[P] };
893
+ /**
894
+ * Extracts keys of an object type that have values of a specific type.
895
+ *
896
+ * @template T - The object type to search
897
+ * @template U - The value type to match
898
+ * @returns A union of keys whose values match the specified type
899
+ *
900
+ * @example
901
+ * ```ts
902
+ * type User = { name: string; age: number; active: boolean };
903
+ * type StringKeys = KeysOfType<User, string>; // 'name'
904
+ * type NumberKeys = KeysOfType<User, number>; // 'age'
905
+ * ```
906
+ */
907
+ type KeysOfType<T, U$1> = { [K in keyof T]: T[K] extends U$1 ? K : never }[keyof T];
908
+ /**
909
+ * Omits properties from an object type that have values of a specific type.
910
+ *
911
+ * @template T - The object type to filter
912
+ * @template U - The value type to exclude
913
+ * @returns An object type without properties of the specified value type
914
+ *
915
+ * @example
916
+ * ```ts
917
+ * type Mixed = { name: string; age: number; active: boolean };
918
+ * type WithoutStrings = OmitByType<Mixed, string>; // { age: number; active: boolean }
919
+ * ```
920
+ */
921
+ type OmitByType<T, U$1> = { [K in keyof T as T[K] extends U$1 ? never : K]: T[K] };
922
+ /**
923
+ * Makes specified properties required while keeping others as-is.
924
+ *
925
+ * @template T - The base object type
926
+ * @template K - The keys to make required
927
+ * @returns An object type with specified properties required
928
+ *
929
+ * @example
930
+ * ```ts
931
+ * type PartialUser = { name?: string; age?: number; email?: string };
932
+ * type RequiredNameUser = RequiredKeys<PartialUser, 'name'>;
933
+ * // { name: string; age?: number; email?: string }
934
+ * ```
935
+ */
936
+ type RequiredKeys<T, K$1 extends keyof T> = Omit<T, K$1> & Required<Pick<T, K$1>>;
937
+ /**
938
+ * Computes the symmetric difference between two object types.
939
+ *
940
+ * Properties that exist in either T or U but not in both.
941
+ *
942
+ * @template T - First object type
943
+ * @template U - Second object type
944
+ * @returns Properties unique to T or U
945
+ *
946
+ * @example
947
+ * ```ts
948
+ * type A = { x: number; y: string };
949
+ * type B = { y: string; z: boolean };
950
+ * type DiffAB = Diff<A, B>; // { x: number; z: boolean }
951
+ * ```
952
+ */
953
+ type Diff<T, U$1> = Omit<T, keyof U$1> & Omit<U$1, keyof T>;
954
+ /**
955
+ * Computes the intersection of two object types (properties present in both).
956
+ *
957
+ * @template T - First object type
958
+ * @template U - Second object type
959
+ * @returns Properties that exist in both T and U
960
+ *
961
+ * @example
962
+ * ```ts
963
+ * type A = { x: number; y: string };
964
+ * type B = { y: string; z: boolean };
965
+ * type IntersectionAB = Intersection<A, B>; // { y: string }
966
+ * ```
967
+ */
968
+ type Intersection<T extends object, U$1 extends object> = Pick<T, Extract<keyof T, keyof U$1> & Extract<keyof U$1, keyof T>>;
969
+ /**
970
+ * Merges two object types, combining their properties.
971
+ *
972
+ * @template T - First object type
973
+ * @template U - Second object type
974
+ * @returns A merged object type with properties from both
975
+ *
976
+ * @example
977
+ * ```ts
978
+ * type A = { x: number; y: string };
979
+ * type B = { y: boolean; z: string };
980
+ * type Merged = Merge<A, B>; // { x: number; y: boolean; z: string }
981
+ * ```
982
+ */
983
+ type Merge<T extends object, U$1 extends object, I = Diff<T, U$1> & Intersection<U$1, T> & Diff<U$1, T>> = Pick<I, keyof I>;
984
+ /**
985
+ * Subtracts properties of one object type from another.
986
+ *
987
+ * @template T - The object type to subtract from
988
+ * @template U - The object type whose properties to subtract
989
+ * @returns T without properties that exist in U
990
+ *
991
+ * @example
992
+ * ```ts
993
+ * type A = { x: number; y: string; z: boolean };
994
+ * type B = { y: string };
995
+ * type Subtracted = Substract<A, B>; // { x: number; z: boolean }
996
+ * ```
997
+ */
998
+ type Substract<T extends object, U$1 extends object> = Omit<T, keyof U$1>;
999
+ /**
1000
+ * Represents either all properties present or none of them.
1001
+ *
1002
+ * Useful for creating mutually exclusive configurations.
1003
+ *
1004
+ * @template T - The object type
1005
+ * @returns Either the full object or an empty object with optional properties
1006
+ *
1007
+ * @example
1008
+ * ```ts
1009
+ * type Config = { host: string; port: number };
1010
+ * type AllOrNoneConfig = AllOrNone<Config>;
1011
+ * // { host: string; port: number } | {}
1012
+ * ```
1013
+ */
1014
+ type AllOrNone<T> = T | { [P in keyof T]?: never };
1015
+ /**
1016
+ * Represents exactly one property from an object type being present.
1017
+ *
1018
+ * Useful for creating discriminated unions or mutually exclusive options.
1019
+ *
1020
+ * @template T - The object type
1021
+ * @returns A union where only one property is present at a time
1022
+ *
1023
+ * @example
1024
+ * ```ts
1025
+ * type Action = { type: 'create'; payload: string } | { type: 'update'; id: number };
1026
+ * type OneAction = OneOf<Action>;
1027
+ * // { type: 'create'; payload: string } | { type: 'update'; id: number }
1028
+ * ```
1029
+ */
1030
+ type OneOf<T> = { [K in keyof T]: Pick<T, K> }[keyof T];
1031
+ /**
1032
+ * Represents exactly two properties from an object type being present.
1033
+ *
1034
+ * @template T - The object type
1035
+ * @returns A union where exactly two properties are present at a time
1036
+ *
1037
+ * @example
1038
+ * ```ts
1039
+ * type Config = { a: number; b: string; c: boolean };
1040
+ * type TwoConfig = TwoOf<Config>;
1041
+ * // { a: number; b: string } | { a: number; c: boolean } | { b: string; c: boolean }
1042
+ * ```
1043
+ */
1044
+ type TwoOf<T> = { [K in keyof T]: { [L in Exclude<keyof T, K>]: Pick<T, K | L> }[Exclude<keyof T, K>] }[keyof T];
1045
+ /**
1046
+ * Prettifies a complex type by expanding it for better readability in tooltips.
1047
+ *
1048
+ * This type doesn't change the runtime type but helps with IntelliSense display.
1049
+ *
1050
+ * @template T - The type to prettify
1051
+ * @returns The same type but expanded for better readability
1052
+ *
1053
+ * @example
1054
+ * ```ts
1055
+ * type Complex = { a: string } & { b: number };
1056
+ * type PrettyComplex = Prettify<Complex>; // Shows as { a: string; b: number }
1057
+ * ```
1058
+ */
1059
+ type Prettify<T> = T extends infer U ? U extends object ? { [K in keyof U]: U[K] } & {} : U : never;
1060
+ /**
1061
+ * Extracts all nested keys of an object type as dot-separated strings.
1062
+ *
1063
+ * @template ObjectType - The object type to extract nested keys from
1064
+ * @template IgnoreKeys - Keys to ignore during extraction
1065
+ * @returns A union of dot-separated string paths
1066
+ *
1067
+ * @example
1068
+ * ```ts
1069
+ * type User = {
1070
+ * name: string;
1071
+ * profile: { age: number; address: { city: string } };
1072
+ * tags: string[];
1073
+ * };
1074
+ *
1075
+ * type UserPaths = NestedKeyOf<User>;
1076
+ * // 'name' | 'profile' | 'profile.age' | 'profile.address' | 'profile.address.city' | 'tags'
1077
+ * ```
1078
+ */
1079
+ type NestedKeyOf<ObjectType extends object, IgnoreKeys extends string = never> = { [Key in keyof ObjectType & string]: Key extends IgnoreKeys ? never : ObjectType[Key] extends object ? ObjectType[Key] extends Array<any> ? Key : `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key], IgnoreKeys>}` : `${Key}` }[keyof ObjectType & string];
1080
+ /**
1081
+ * Creates a type that excludes properties present in another type.
1082
+ *
1083
+ * This is useful for creating mutually exclusive types.
1084
+ *
1085
+ * @template T - The base type
1086
+ * @template U - The type whose properties to exclude
1087
+ * @returns A type with properties from T that are not in U
1088
+ *
1089
+ * @example
1090
+ * ```ts
1091
+ * type A = { x: number; y: string };
1092
+ * type B = { y: string };
1093
+ * type WithoutB = Without<A, B>; // { x?: never }
1094
+ * ```
1095
+ */
1096
+ type Without<T, U$1> = { [P in Exclude<keyof T, keyof U$1>]?: never };
1097
+ //#endregion
1098
+ //#region src/types/gates.d.ts
1099
+ type BUFFER<T> = T;
1100
+ type IMPLIES<T, U$1> = T extends U$1 ? true : false;
1101
+ type XOR_Binary<T, U$1> = T | U$1 extends object ? (Without<T, U$1> & U$1) | (Without<U$1, T> & T) : T | U$1;
1102
+ type XNOR_Binary<T, U$1> = (T & U$1) | (Without<T, U$1> & Without<U$1, T>);
1103
+ /**
1104
+ * Computes a type-level AND (all must true) for a tuple of types.
1105
+ *
1106
+ * Truth table for 3 arguments:
1107
+ *
1108
+ * A B C = AND
1109
+ * 1 1 1 = 1
1110
+ * 1 1 0 = 0
1111
+ * 1 0 1 = 0
1112
+ * 1 0 0 = 0
1113
+ * 0 1 1 = 0
1114
+ * 0 1 0 = 0
1115
+ * 0 0 1 = 0
1116
+ * 0 0 0 = 0
1117
+ *
1118
+ * @template T - Tuple of boolean-like types (1/0)
1119
+ */
1120
+ type AND<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F & AND<R> : F : unknown;
1121
+ /**
1122
+ * Computes a type-level OR (At least one) for a tuple of types.
1123
+ *
1124
+ * Truth table for 3 arguments:
1125
+ *
1126
+ * A B C = OR
1127
+ * 1 1 1 = 1
1128
+ * 1 1 0 = 1
1129
+ * 1 0 1 = 1
1130
+ * 1 0 0 = 1
1131
+ * 0 1 1 = 1
1132
+ * 0 1 0 = 1
1133
+ * 0 0 1 = 1
1134
+ * 0 0 0 = 0
1135
+ *
1136
+ * @template T - Tuple of boolean-like types (1/0)
1137
+ */
1138
+ type OR<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F | OR<R> : F : never;
1139
+ /**
1140
+ * Computes a type-level XOR (only one/odd) for a tuple of types.
1141
+ *
1142
+ * Truth table for 3 arguments:
1143
+ *
1144
+ * A B C = XOR
1145
+ * 1 1 1 = 1
1146
+ * 1 1 0 = 0
1147
+ * 1 0 1 = 0
1148
+ * 1 0 0 = 1
1149
+ * 0 1 1 = 0
1150
+ * 0 1 0 = 1
1151
+ * 0 0 1 = 1
1152
+ * 0 0 0 = 0
1153
+ *
1154
+ * @template T - Tuple of boolean-like types (1/0)
1155
+ */
1156
+ type XOR<T extends any[]> = T extends [infer F, ...infer R] ? R extends [infer S, ...infer Rest] ? XOR<[XOR_Binary<F, S>, ...Rest]> : F : never;
1157
+ /**
1158
+ * Computes a type-level XNOR (All or None true) for a tuple of types.
1159
+ *
1160
+ * Truth table for 3 arguments:
1161
+ *
1162
+ * A B C = XNOR
1163
+ * 1 1 1 = 0
1164
+ * 1 1 0 = 1
1165
+ * 1 0 1 = 1
1166
+ * 1 0 0 = 0
1167
+ * 0 1 1 = 1
1168
+ * 0 1 0 = 0
1169
+ * 0 0 1 = 0
1170
+ * 0 0 0 = 1
1171
+ *
1172
+ * @template T - Tuple of boolean-like types (1/0)
1173
+ */
1174
+ type XNOR<T extends any[]> = T extends [infer F, ...infer R] ? R extends [infer S, ...infer Rest] ? XNOR<[XNOR_Binary<F, S>, ...Rest]> : F : never;
1175
+ /**
1176
+ * Computes a type-level NOT for a tuple of types.
1177
+ *
1178
+ * Truth table for 3 arguments:
1179
+ *
1180
+ * A B C = NOT
1181
+ * 1 1 1 = 0
1182
+ * 1 1 0 = 0
1183
+ * 1 0 1 = 0
1184
+ * 1 0 0 = 0
1185
+ * 0 1 1 = 0
1186
+ * 0 1 0 = 0
1187
+ * 0 0 1 = 0
1188
+ * 0 0 0 = 1
1189
+ *
1190
+ * @template T - Tuple of boolean-like types (1/0)
1191
+ */
1192
+ type NOT<T> = { [P in keyof T]?: never };
1193
+ /**
1194
+ * Computes a type-level NAND for a tuple of types.
1195
+ *
1196
+ * Truth table for 3 arguments:
1197
+ *
1198
+ * A B C = NAND
1199
+ * 1 1 1 = 0
1200
+ * 1 1 0 = 1
1201
+ * 1 0 1 = 1
1202
+ * 1 0 0 = 1
1203
+ * 0 1 1 = 1
1204
+ * 0 1 0 = 1
1205
+ * 0 0 1 = 1
1206
+ * 0 0 0 = 1
1207
+ *
1208
+ * @template T - Tuple of boolean-like types (1/0)
1209
+ */
1210
+ type NAND<T extends any[]> = NOT<AND<T>>;
1211
+ /**
1212
+ * Computes a type-level NOR for a tuple of types.
1213
+ *
1214
+ * Truth table for 3 arguments:
1215
+ *
1216
+ * A B C = NOR
1217
+ * 1 1 1 = 0
1218
+ * 1 1 0 = 0
1219
+ * 1 0 1 = 0
1220
+ * 1 0 0 = 0
1221
+ * 0 1 1 = 0
1222
+ * 0 1 0 = 0
1223
+ * 0 0 1 = 0
1224
+ * 0 0 0 = 1
1225
+ *
1226
+ * @template T - Tuple of boolean-like types (1/0)
1227
+ */
1228
+ type NOR<T extends any[]> = NOT<OR<T>>;
1229
+ //#endregion
1230
+ //#region src/types/guards.d.ts
1231
+ /**
1232
+ * Represents primitive JavaScript types including null and undefined.
1233
+ */
1234
+ type Primitive = string | number | bigint | boolean | symbol | null | undefined;
1235
+ /**
1236
+ * Represents all falsy values in JavaScript.
1237
+ */
1238
+ type Falsy = false | '' | 0 | null | undefined;
1239
+ /**
1240
+ * Type guard that checks if a value is falsy.
1241
+ *
1242
+ * @param val - The value to check
1243
+ * @returns True if the value is falsy, false otherwise
1244
+ *
1245
+ * @example
1246
+ * if (isFalsy(value)) {
1247
+ * console.log('Value is falsy');
1248
+ * }
1249
+ */
1250
+ declare const isFalsy: (val: unknown) => val is Falsy;
1251
+ /**
1252
+ * Type guard that checks if a value is null or undefined.
1253
+ *
1254
+ * @param val - The value to check
1255
+ * @returns True if the value is null or undefined, false otherwise
1256
+ *
1257
+ * @example
1258
+ * if (isNullish(value)) {
1259
+ * console.log('Value is null or undefined');
1260
+ * }
1261
+ */
1262
+ declare const isNullish: (val: unknown) => val is null | undefined;
1263
+ /**
1264
+ * Type guard that checks if a value is a primitive type.
1265
+ *
1266
+ * @param val - The value to check
1267
+ * @returns True if the value is a primitive, false otherwise
1268
+ *
1269
+ * @example
1270
+ * if (isPrimitive(value)) {
1271
+ * console.log('Value is a primitive type');
1272
+ * }
1273
+ */
1274
+ declare const isPrimitive: (val: unknown) => val is Primitive;
1275
+ /**
1276
+ * Type guard that checks if a value is a plain object (not an array, function, etc.).
1277
+ *
1278
+ * @param value - The value to check
1279
+ * @returns True if the value is a plain object, false otherwise
1280
+ *
1281
+ * @example
1282
+ * if (isPlainObject(value)) {
1283
+ * console.log('Value is a plain object');
1284
+ * }
1285
+ */
1286
+ declare function isPlainObject(value: unknown): value is Record<string, any>;
1287
+ //#endregion
1288
+ export { AND, AllOrNone, BUFFER, DeepMergeOptions, DeepPartial, DeepReadonly, DeepRequired, Diff, Falsy, IMPLIES, Intersection, Keys, KeysOfType, Maybe, Merge, Mutable, NAND, NOR, NOT, NestedKeyOf, Never, Nullable, Nullish, OR, OmitByType, OneOf, Optional, Prettify, Primitive, RequiredKeys, ScheduleOpts, SelectivePartial, SelectiveRequired, Substract, Task, TwoOf, Values, Without, XNOR, XNOR_Binary, XOR, XOR_Binary, convertToNormalCase, convertToSlug, debounce, deepmerge, escapeRegExp, extendProps, getObjectValue, hydrate, isFalsy, isNullish, isPlainObject, isPrimitive, normalizeText, poll, printf, schedule, shield, sleep, throttle };