@sohanemon/utils 6.4.6 → 7.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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { n as Task, r as schedule, t as ScheduleOpts } from "./schedule-BqFAJlSO.cjs";
2
1
  import * as React from "react";
3
2
  import { ClassValue } from "clsx";
3
+ export * from "@ts-utilities/core";
4
4
 
5
5
  //#region src/functions/cookie.d.ts
6
6
 
@@ -62,416 +62,6 @@ declare const getClientSideCookie: (name: string) => {
62
62
  value: string | undefined;
63
63
  };
64
64
  //#endregion
65
- //#region src/functions/deepmerge.d.ts
66
- type TAllKeys<T> = T extends any ? keyof T : never;
67
- type TIndexValue<T, K$1 extends PropertyKey, D = never> = T extends any ? K$1 extends keyof T ? T[K$1] : D : never;
68
- 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;
69
- type TFunction = (...a: any[]) => any;
70
- type TPrimitives = string | number | boolean | bigint | symbol | Date | TFunction;
71
- type DeepMergeOptions = {
72
- arrayMerge?: 'replace' | 'concat' | 'merge' | ((target: any[], source: any[]) => any[]);
73
- clone?: boolean;
74
- customMerge?: (key: string | symbol, targetValue: any, sourceValue: any) => any;
75
- functionMerge?: 'replace' | 'compose';
76
- maxDepth?: number;
77
- };
78
- 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;
79
- /**
80
- * Deeply merges multiple objects, with later sources taking precedence.
81
- * Handles nested objects, arrays, and special object types with circular reference detection.
82
- *
83
- * Features:
84
- * - Deep merging of nested objects
85
- * - Configurable array merging strategies
86
- * - Circular reference detection and handling
87
- * - Support for symbols and special objects (Date, RegExp, etc.)
88
- * - Type-safe with improved generics
89
- * - Optional cloning to avoid mutation
90
- * - Custom merge functions for specific keys
91
- *
92
- * @template T - The target object type
93
- * @param target - The target object to merge into
94
- * @param sources - Source objects to merge from (can have additional properties)
95
- * @param options - Configuration options
96
- * @param options.clone - Whether to clone the target (default: true)
97
- * @param options.customMerge - Custom merge function for specific keys
98
- * @param options.arrayMerge - How to merge arrays: 'replace' (default), 'concat', or 'merge'
99
- * @param options.functionMerge - How to merge functions: 'replace' (default) or 'compose'
100
- * @param options.maxDepth - Maximum recursion depth (default: 100)
101
- * @returns The merged object with proper typing
102
- *
103
- * @example
104
- * // Basic shallow merge
105
- * deepmerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
106
- *
107
- * @example
108
- * // Deep merge of nested objects
109
- * deepmerge({ user: { name: 'John' } }, { user: { age: 30 } })
110
- * // { user: { name: 'John', age: 30 } }
111
- *
112
- * @example
113
- * // Array concatenation
114
- * deepmerge({ tags: ['react'] }, { tags: ['typescript'] }, { arrayMerge: 'concat' })
115
- * // { tags: ['react', 'typescript'] }
116
- *
117
- * @example
118
- * // Array replacement (default)
119
- * deepmerge({ items: [1, 2] }, { items: [3, 4] })
120
- * // { items: [3, 4] }
121
- *
122
- * @example
123
- * // Custom array merging
124
- * deepmerge(
125
- * { scores: [85, 90] },
126
- * { scores: [95] },
127
- * { arrayMerge: (target, source) => [...target, ...source] }
128
- * )
129
- * // { scores: [85, 90, 95] }
130
- *
131
- * @example
132
- * // Configuration merging
133
- * const defaultConfig = { theme: 'light', features: { darkMode: false } };
134
- * const userConfig = { theme: 'dark', features: { darkMode: true, animations: true } };
135
- * deepmerge(defaultConfig, userConfig);
136
- * // { theme: 'dark', features: { darkMode: true, animations: true } }
137
- *
138
- * @example
139
- * // State updates in reducers
140
- * const initialState = { user: { profile: { name: '' } }, settings: {} };
141
- * const action = { user: { profile: { name: 'Alice' } }, settings: { theme: 'dark' } };
142
- * const newState = deepmerge(initialState, action);
143
- *
144
- * @example
145
- * // Merging API responses
146
- * const cachedData = { posts: [{ id: 1, title: 'Old' }] };
147
- * const freshData = { posts: [{ id: 1, title: 'Updated', author: 'Bob' }] };
148
- * deepmerge(cachedData, freshData);
149
- * // { posts: [{ id: 1, title: 'Updated', author: 'Bob' }] }
150
- *
151
- * @example
152
- * // Function composition
153
- * const log1 = () => console.log('first');
154
- * const log2 = () => console.log('second');
155
- * const composed = deepmerge(log1, log2, { functionMerge: 'compose' });
156
- * composed(); // logs 'first' then 'second'
157
- */
158
- declare function deepmerge<T extends Record<string, any>, S$1 extends Record<string, any>[]>(target: T, ...sources: S$1): TMerged<T | S$1[number]>;
159
- 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]>;
160
- //#endregion
161
- //#region src/functions/hydrate.d.ts
162
- type Hydrate<T> = T extends null ? undefined : T extends (infer U)[] ? Hydrate<U>[] : T extends object ? { [K in keyof T]: Hydrate<T[K]> } : T;
163
- /**
164
- * Converts all `null` values to `undefined` in the data structure recursively.
165
- *
166
- * @param data - Any input data (object, array, primitive)
167
- * @returns Same type as input, but with all nulls replaced by undefined
168
- *
169
- * @example
170
- * ```ts
171
- * // Basic object hydration
172
- * hydrate({ name: null, age: 25 }) // { name: undefined, age: 25 }
173
- *
174
- * // Nested object hydration
175
- * hydrate({
176
- * user: { email: null, profile: { avatar: null } },
177
- * settings: { theme: 'dark' }
178
- * })
179
- * // { user: { email: undefined, profile: { avatar: undefined } }, settings: { theme: 'dark' } }
180
- *
181
- * // Array hydration
182
- * hydrate([null, 'hello', null, 42]) // [undefined, 'hello', undefined, 42]
183
- *
184
- * // Mixed data structures
185
- * hydrate({
186
- * posts: [null, { title: 'Hello', content: null }],
187
- * metadata: { published: null, tags: ['react', null] }
188
- * })
189
- * ```
190
- *
191
- * @example
192
- * ```ts
193
- * // API response normalization
194
- * const apiResponse = await fetch('/api/user');
195
- * const rawData = await apiResponse.json(); // May contain null values
196
- * const normalizedData = hydrate(rawData); // Convert nulls to undefined
197
- *
198
- * // Database result processing
199
- * const dbResult = query('SELECT * FROM users'); // Some fields may be NULL
200
- * const cleanData = hydrate(dbResult); // Normalize for consistent handling
201
- *
202
- * // Form data sanitization
203
- * const formData = getFormValues(); // May have null values from empty fields
204
- * const sanitizedData = hydrate(formData); // Prepare for validation/state
205
- * ```
206
- */
207
- declare function hydrate<T>(data: T): Hydrate<T>;
208
- //#endregion
209
- //#region src/functions/object.d.ts
210
- /**
211
- * Type representing a path split into segments
212
- * @template S - The original path string type
213
- */
214
- type SplitPath<S$1 extends string> = S$1 extends `${infer First}.${infer Rest}` ? [First, ...SplitPath<Rest>] : [S$1];
215
- /**
216
- * Recursive type to resolve nested object types based on path
217
- * @template T - Current object type
218
- * @template K - Array of path segments
219
- */
220
- 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;
221
- /**
222
- * Get a nested value from an object using array path segments
223
- * @template T - Object type
224
- * @template K - Path segments array type
225
- * @template D - Default value type
226
- * @param obj - Source object
227
- * @param path - Array of path segments
228
- * @param defaultValue - Fallback value if path not found
229
- * @returns Value at path or default value
230
- *
231
- * @example
232
- * getObjectValue({a: [{b: 1}]}, ['a', 0, 'b']) // 1
233
- */
234
- 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;
235
- /**
236
- * Get a nested value from an object using array path segments
237
- * @template T - Object type
238
- * @template K - Path segments array type
239
- * @param obj - Source object
240
- * @param path - Array of path segments
241
- * @returns Value at path or undefined
242
- *
243
- * @example
244
- * getObjectValue({a: [{b: 1}]}, ['a', 0, 'b']) // 1
245
- */
246
- declare function getObjectValue<T, K$1 extends Array<string | number>>(obj: T, path: K$1): GetValue<T, K$1> | undefined;
247
- /**
248
- * Get a nested value from an object using dot notation path
249
- * @template T - Object type
250
- * @template S - Path string literal type
251
- * @template D - Default value type
252
- * @param obj - Source object
253
- * @param path - Dot-separated path string
254
- * @param defaultValue - Fallback value if path not found
255
- * @returns Value at path or default value
256
- *
257
- * @example
258
- * getObjectValue({a: [{b: 1}]}, 'a.0.b', 2) // 1
259
- */
260
- declare function getObjectValue<T, S$1 extends string, D>(obj: T, path: S$1, defaultValue: D): Exclude<GetValue<T, SplitPath<S$1>>, undefined> | D;
261
- /**
262
- * Get a nested value from an object using dot notation path
263
- * @template T - Object type
264
- * @template S - Path string literal type
265
- * @param obj - Source object
266
- * @param path - Dot-separated path string
267
- * @returns Value at path or undefined
268
- *
269
- * @example
270
- * getObjectValue({a: [{b: 1}]}, 'a.0.b') // 1
271
- */
272
- declare function getObjectValue<T, S$1 extends string>(obj: T, path: S$1): GetValue<T, SplitPath<S$1>> | undefined;
273
- /**
274
- * Extend an object or function with additional properties while
275
- * preserving the original type information.
276
- *
277
- * Works with both plain objects and callable functions since
278
- * functions in JavaScript are objects too.
279
- *
280
- * @template T The base object or function type
281
- * @template P The additional properties type
282
- *
283
- * @param base - The object or function to extend
284
- * @param props - An object containing properties to attach
285
- *
286
- * @returns The same object/function, augmented with the given properties
287
- *
288
- * @example
289
- * ```ts
290
- * // Extend a plain object
291
- * const config = extendProps({ apiUrl: '/api' }, { timeout: 5000 });
292
- * // config has both apiUrl and timeout properties
293
- *
294
- * // Extend a function with metadata
295
- * const fetchData = (url: string) => fetch(url).then(r => r.json());
296
- * const enhancedFetch = extendProps(fetchData, {
297
- * description: 'Data fetching utility',
298
- * version: '1.0'
299
- * });
300
- * // enhancedFetch is callable and has description/version properties
301
- *
302
- * // Create plugin system
303
- * const basePlugin = { name: 'base', enabled: true };
304
- * const authPlugin = extendProps(basePlugin, {
305
- * authenticate: (token: string) => validateToken(token)
306
- * });
307
- *
308
- * // Build configuration objects
309
- * const defaultSettings = { theme: 'light', lang: 'en' };
310
- * const userSettings = extendProps(defaultSettings, {
311
- * theme: 'dark',
312
- * notifications: true
313
- * });
314
- * ```
315
- */
316
- declare function extendProps<T extends object, P$1 extends object>(base: T, props: P$1): T & P$1;
317
- //#endregion
318
- //#region src/functions/poll.d.ts
319
- /**
320
- * Repeatedly polls an async `cond` function UNTIL it returns a TRUTHY value,
321
- * or until the operation times out or is aborted.
322
- *
323
- * Designed for waiting on async jobs, external state, or delayed availability.
324
- *
325
- * @template T The type of the successful result.
326
- *
327
- * @param cond
328
- * A function returning a Promise that resolves to:
329
- * - a truthy value `T` → stop polling and return it
330
- * - falsy/null/undefined → continue polling
331
- *
332
- * @param options
333
- * Configuration options:
334
- * - `interval` (number) — Time between polls in ms (default: 5000 ms)
335
- * - `timeout` (number) — Max total duration before failing (default: 5 min)
336
- * - `jitter` (boolean) — Add small random offset (±10%) to intervals to avoid sync bursts (default: true)
337
- * - `signal` (AbortSignal) — Optional abort signal to cancel polling
338
- *
339
- * @returns
340
- * Resolves with the truthy value `T` when successful.
341
- * Throws `AbortError` if aborted
342
- *
343
- * @example
344
- * ```ts
345
- * // Poll for job completion
346
- * const job = await poll(async () => {
347
- * const status = await getJobStatus();
348
- * return status === 'done' ? status : null;
349
- * }, { interval: 3000, timeout: 60000 });
350
- * ```
351
- *
352
- * @example
353
- * ```ts
354
- * // Wait for API endpoint to be ready
355
- * const apiReady = await poll(async () => {
356
- * try {
357
- * await fetch('/api/health');
358
- * return true;
359
- * } catch {
360
- * return null;
361
- * }
362
- * }, { interval: 1000, timeout: 30000 });
363
- * ```
364
- *
365
- * @example
366
- * ```ts
367
- * // Poll with abort signal for cancellation
368
- * const controller = new AbortController();
369
- * setTimeout(() => controller.abort(), 10000); // Cancel after 10s
370
- *
371
- * try {
372
- * const result = await poll(
373
- * () => checkExternalService(),
374
- * { interval: 2000, signal: controller.signal }
375
- * );
376
- * } catch (err) {
377
- * if (err.name === 'AbortError') {
378
- * console.log('Polling was cancelled');
379
- * }
380
- * }
381
- * ```
382
- *
383
- * @example
384
- * ```ts
385
- * // Poll for user action completion
386
- * const userConfirmed = await poll(async () => {
387
- * const confirmations = await getPendingConfirmations();
388
- * return confirmations.length > 0 ? confirmations[0] : null;
389
- * }, { interval: 5000, timeout: 300000 }); // 5 min timeout
390
- * ```
391
- */
392
- declare function poll<T>(cond: () => Promise<T | null | false | undefined>, {
393
- interval,
394
- timeout,
395
- jitter,
396
- signal
397
- }?: Partial<{
398
- interval: number;
399
- timeout: number;
400
- signal: AbortSignal;
401
- jitter: boolean;
402
- }>): Promise<T>;
403
- //#endregion
404
- //#region src/functions/shield.d.ts
405
- /**
406
- * A helper to run sync or async operations safely without try/catch.
407
- *
408
- * Returns a tuple `[error, data]`:
409
- * - `error`: the thrown error (if any), otherwise `null`
410
- * - `data`: the resolved value (if successful), otherwise `null`
411
- *
412
- * @example
413
- * ```ts
414
- * // Synchronous error handling
415
- * const [err, value] = shield(() => {
416
- * if (Math.random() > 0.5) throw new Error('Random failure');
417
- * return 'success';
418
- * });
419
- * if (err) {
420
- * console.error('Operation failed:', err);
421
- * } else {
422
- * console.log('Result:', value);
423
- * }
424
- *
425
- * // Asynchronous error handling
426
- * const [asyncErr, result] = await shield(async () => {
427
- * const response = await fetch('/api/data');
428
- * if (!response.ok) throw new Error('API error');
429
- * return response.json();
430
- * });
431
- * if (asyncErr) {
432
- * console.error('API call failed:', asyncErr);
433
- * } else {
434
- * processData(result);
435
- * }
436
- *
437
- * // API calls with fallbacks
438
- * const [fetchErr, data] = await shield(fetchUserData(userId));
439
- * const userData = fetchErr ? getCachedUserData(userId) : data;
440
- *
441
- * // File operations
442
- * const [fileErr, content] = shield(() => readFileSync('config.json'));
443
- * if (fileErr) {
444
- * console.warn('Could not read config, using defaults');
445
- * return defaultConfig;
446
- * }
447
- * ```
448
- *
449
- * @example
450
- * ```ts
451
- * // In async functions
452
- * async function safeApiCall() {
453
- * const [err, result] = await shield(callExternalAPI());
454
- * if (err) {
455
- * await logError(err);
456
- * return null;
457
- * }
458
- * return result;
459
- * }
460
- *
461
- * // In event handlers
462
- * function handleSubmit(formData) {
463
- * const [validationErr, validatedData] = shield(() => validateForm(formData));
464
- * if (validationErr) {
465
- * showValidationError(validationErr);
466
- * return;
467
- * }
468
- * submitData(validatedData);
469
- * }
470
- * ```
471
- */
472
- declare function shield<T, E = Error>(operation: Promise<T>): Promise<[E | null, T | null]>;
473
- declare function shield<T, E = Error>(operation: () => T): [E | null, T | null];
474
- //#endregion
475
65
  //#region src/functions/utils.d.ts
476
66
  /**
477
67
  * Utility to merge class names with Tailwind CSS and additional custom merging logic.
@@ -491,8 +81,8 @@ declare function cn(...inputs: ClassValue[]): string;
491
81
  *
492
82
  * Determines if a navigation link is active based on the current path.
493
83
  *
494
- * @param href - The target URL.
495
- * @param path - The current browser path.
84
+ * @param href - The target URL.
85
+ * @param path - The current browser path.
496
86
  * @returns - True if the navigation is active, false otherwise.
497
87
  *
498
88
  * @example
@@ -593,36 +183,6 @@ declare const scrollTo: (containerSelector: string | React.RefObject<HTMLDivElem
593
183
  * ```
594
184
  */
595
185
  declare const copyToClipboard: (value: string, onSuccess?: () => void) => void;
596
- /**
597
- * Converts various case styles (camelCase, PascalCase, kebab-case, snake_case) into readable normal case.
598
- *
599
- * Transforms technical naming conventions into human-readable titles by:
600
- * - Adding spaces between words
601
- * - Capitalizing the first letter of each word
602
- * - Handling common separators (-, _, camelCase boundaries)
603
- *
604
- * @param inputString - The string to convert (supports camelCase, PascalCase, kebab-case, snake_case).
605
- * @returns The converted string in normal case (title case).
606
- *
607
- * @example
608
- * ```ts
609
- * convertToNormalCase('camelCase') // 'Camel Case'
610
- * convertToNormalCase('kebab-case') // 'Kebab Case'
611
- * convertToNormalCase('snake_case') // 'Snake Case'
612
- * convertToNormalCase('PascalCase') // 'Pascal Case'
613
- * ```
614
- */
615
- declare function convertToNormalCase(inputString: string): string;
616
- /**
617
- * Converts a string to a URL-friendly slug by trimming, converting to lowercase,
618
- * replacing diacritics, removing invalid characters, and replacing spaces with hyphens.
619
- * @param {string} [str] - The input string to convert.
620
- * @returns {string} The generated slug.
621
- * @example
622
- * convertToSlug("Hello World!"); // "hello-world"
623
- * convertToSlug("Déjà Vu"); // "deja-vu"
624
- */
625
- declare const convertToSlug: (str: string) => string;
626
186
  /**
627
187
  * Checks if the code is running in a server-side environment.
628
188
  *
@@ -654,154 +214,6 @@ declare const isSSR: boolean;
654
214
  * ```
655
215
  */
656
216
  declare const svgToBase64: (str: string) => string;
657
- /**
658
- * Pauses execution for the specified time.
659
- *
660
- * `signal` allows cancelling the sleep via AbortSignal.
661
- *
662
- * @param time - Time in milliseconds to sleep (default is 1000ms)
663
- * @param signal - Optional AbortSignal to cancel the sleep early
664
- * @returns - A Promise that resolves after the specified time or when aborted
665
- */
666
- declare const sleep: (time?: number, signal?: AbortSignal) => Promise<void>;
667
- type DebouncedFunction<F$1 extends (...args: any[]) => any> = {
668
- (...args: Parameters<F$1>): ReturnType<F$1> | undefined;
669
- readonly isPending: boolean;
670
- };
671
- /**
672
- * Creates a debounced function that delays invoking the provided function until
673
- * after the specified `wait` time has elapsed since the last invocation.
674
- *
675
- * If the `immediate` option is set to `true`, the function will be invoked immediately
676
- * on the leading edge of the wait interval. Subsequent calls during the wait interval
677
- * will reset the timer but not invoke the function until the interval elapses again.
678
- *
679
- * The returned function includes the `isPending` property to check if the debounce
680
- * timer is currently active.
681
- *
682
- * @typeParam F - The type of the function to debounce.
683
- *
684
- * @param function_ - The function to debounce.
685
- * @param wait - The number of milliseconds to delay (default is 100ms).
686
- * @param options - An optional object with the following properties:
687
- * - `immediate` (boolean): If `true`, invokes the function on the leading edge
688
- * of the wait interval instead of the trailing edge.
689
- *
690
- * @returns A debounced version of the provided function, enhanced with the `isPending` property.
691
- *
692
- * @throws {TypeError} If the first parameter is not a function.
693
- * @throws {RangeError} If the `wait` parameter is negative.
694
- *
695
- * @example
696
- * ```ts
697
- * // Basic debouncing
698
- * const log = debounce((message: string) => console.log(message), 200);
699
- * log('Hello'); // Logs "Hello" after 200ms if no other call is made.
700
- * console.log(log.isPending); // true if the timer is active.
701
- *
702
- * // Immediate execution
703
- * const save = debounce(() => saveToServer(), 500, { immediate: true });
704
- * save(); // Executes immediately, then waits 500ms for subsequent calls
705
- *
706
- * // Check pending state
707
- * const debouncedSearch = debounce(searchAPI, 300);
708
- * debouncedSearch('query');
709
- * if (debouncedSearch.isPending) {
710
- * showLoadingIndicator();
711
- * }
712
- * ```
713
- */
714
- declare function debounce<F$1 extends (...args: any[]) => any>(function_: F$1, wait?: number, options?: {
715
- immediate: boolean;
716
- }): DebouncedFunction<F$1>;
717
- type ThrottledFunction<F$1 extends (...args: any[]) => any> = {
718
- (...args: Parameters<F$1>): ReturnType<F$1> | undefined;
719
- readonly isPending: boolean;
720
- };
721
- /**
722
- * Creates a throttled function that invokes the provided function at most once
723
- * every `wait` milliseconds.
724
- *
725
- * If the `leading` option is set to `true`, the function will be invoked immediately
726
- * on the leading edge of the throttle interval. If the `trailing` option is set to `true`,
727
- * the function will also be invoked at the end of the throttle interval if additional
728
- * calls were made during the interval.
729
- *
730
- * The returned function includes the `isPending` property to check if the throttle
731
- * timer is currently active.
732
- *
733
- * @typeParam F - The type of the function to throttle.
734
- *
735
- * @param function_ - The function to throttle.
736
- * @param wait - The number of milliseconds to wait between invocations (default is 100ms).
737
- * @param options - An optional object with the following properties:
738
- * - `leading` (boolean): If `true`, invokes the function on the leading edge of the interval.
739
- * - `trailing` (boolean): If `true`, invokes the function on the trailing edge of the interval.
740
- *
741
- * @returns A throttled version of the provided function, enhanced with the `isPending` property.
742
- *
743
- * @throws {TypeError} If the first parameter is not a function.
744
- * @throws {RangeError} If the `wait` parameter is negative.
745
- *
746
- * @example
747
- * ```ts
748
- * // Basic throttling (leading edge by default)
749
- * const log = throttle((message: string) => console.log(message), 200);
750
- * log('Hello'); // Logs "Hello" immediately
751
- * log('World'); // Ignored for 200ms
752
- * console.log(log.isPending); // true if within throttle window
753
- *
754
- * // Trailing edge only
755
- * const trailingLog = throttle(() => console.log('trailing'), 200, {
756
- * leading: false,
757
- * trailing: true
758
- * });
759
- * trailingLog(); // No immediate execution
760
- * // After 200ms: logs "trailing"
761
- *
762
- * // Both edges
763
- * const bothLog = throttle(() => console.log('both'), 200, {
764
- * leading: true,
765
- * trailing: true
766
- * });
767
- * bothLog(); // Immediate execution
768
- * // After 200ms: executes again if called during window
769
- * ```
770
- */
771
- declare function throttle<F$1 extends (...args: any[]) => any>(function_: F$1, wait?: number, options?: {
772
- leading?: boolean;
773
- trailing?: boolean;
774
- }): ThrottledFunction<F$1>;
775
- /**
776
- * Formats a string by replacing each '%s' placeholder with the corresponding argument.
777
- *
778
- * Mimics the basic behavior of C's printf for %s substitution. Supports both
779
- * variadic arguments and array-based argument passing. Extra placeholders
780
- * are left as-is, missing arguments result in empty strings.
781
- *
782
- * @param format - The format string containing '%s' placeholders.
783
- * @param args - The values to substitute, either as separate arguments or a single array.
784
- * @returns The formatted string with placeholders replaced by arguments.
785
- *
786
- * @example
787
- * ```ts
788
- * // Basic usage with separate arguments
789
- * printf("%s love %s", "I", "Bangladesh") // "I love Bangladesh"
790
- *
791
- * // Using array of arguments
792
- * printf("%s love %s", ["I", "Bangladesh"]) // "I love Bangladesh"
793
- *
794
- * // Extra placeholders remain unchanged
795
- * printf("%s %s %s", "Hello", "World") // "Hello World %s"
796
- *
797
- * // Missing arguments become empty strings
798
- * printf("%s and %s", "this") // "this and "
799
- *
800
- * // Multiple occurrences
801
- * printf("%s %s %s", "repeat", "repeat", "repeat") // "repeat repeat repeat"
802
- * ```
803
- */
804
- declare function printf(format: string, ...args: unknown[]): string;
805
217
  /**
806
218
  * Merges multiple refs into a single ref callback.
807
219
  *
@@ -841,47 +253,6 @@ declare const mergeRefs: MergeRefs;
841
253
  * ```
842
254
  */
843
255
  declare function goToClientSideHash(id: string, opts?: ScrollIntoViewOptions): void;
844
- /**
845
- * Escapes a string for use in a regular expression.
846
- *
847
- * @param str - The string to escape
848
- * @returns - The escaped string safe for use in RegExp constructor
849
- *
850
- * @example
851
- * ```ts
852
- * const escapedString = escapeRegExp('Hello, world!');
853
- * // escapedString === 'Hello\\, world!'
854
- *
855
- * const regex = new RegExp(escapeRegExp(userInput));
856
- * ```
857
- */
858
- declare function escapeRegExp(str: string): string;
859
- /**
860
- * Normalizes a string by:
861
- * - Applying Unicode normalization (NFC)
862
- * - Optionally removing diacritic marks (accents)
863
- * - Optionally trimming leading/trailing non-alphanumeric characters
864
- * - Optionally converting to lowercase
865
- *
866
- * @param str - The string to normalize
867
- * @param options - Normalization options
868
- * @param options.lowercase - Whether to convert the result to lowercase (default: true)
869
- * @param options.removeAccents - Whether to remove diacritic marks like accents (default: true)
870
- * @param options.removeNonAlphanumeric - Whether to trim non-alphanumeric characters from the edges (default: true)
871
- * @returns The normalized string
872
- *
873
- * @example
874
- * ```ts
875
- * normalizeText('Café') // 'cafe'
876
- * normalizeText(' Hello! ') // 'hello'
877
- * normalizeText('José', { removeAccents: false }) // 'josé'
878
- * ```
879
- */
880
- declare function normalizeText(str?: string | null, options?: {
881
- lowercase?: boolean;
882
- removeAccents?: boolean;
883
- removeNonAlphanumeric?: boolean;
884
- }): string;
885
256
  //#endregion
886
257
  //#region src/functions/worker.d.ts
887
258
  /**
@@ -921,613 +292,4 @@ declare function normalizeText(str?: string | null, options?: {
921
292
  */
922
293
  declare function workerize<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => Promise<ReturnType<T>>;
923
294
  //#endregion
924
- //#region src/types/utilities.d.ts
925
- /**
926
- * Extracts the keys of an object type as a union type.
927
- *
928
- * @template T - The object type to extract keys from
929
- * @returns A union of all keys in the object type
930
- *
931
- * @example
932
- * ```ts
933
- * type User = { name: string; age: number };
934
- * type UserKeys = Keys<User>; // 'name' | 'age'
935
- * ```
936
- */
937
- type Keys<T extends object> = keyof T;
938
- /**
939
- * Extracts the values of an object type as a union type.
940
- *
941
- * @template T - The object type to extract values from
942
- * @returns A union of all values in the object type
943
- *
944
- * @example
945
- * ```ts
946
- * type User = { name: string; age: number };
947
- * type UserValues = Values<User>; // string | number
948
- * ```
949
- */
950
- type Values<T extends object> = T[keyof T];
951
- /**
952
- * Makes all properties of an object type optional recursively.
953
- *
954
- * This type traverses through nested objects and arrays, making all properties optional.
955
- * Functions and primitives are left unchanged.
956
- *
957
- * @template T - The type to make deeply partial
958
- * @returns A type with all properties optional recursively
959
- *
960
- * @example
961
- * ```ts
962
- * type Config = {
963
- * server: { host: string; port: number };
964
- * features: string[];
965
- * };
966
- *
967
- * type PartialConfig = DeepPartial<Config>;
968
- * // {
969
- * // server?: { host?: string; port?: number };
970
- * // features?: string[];
971
- * // }
972
- * ```
973
- */
974
- 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;
975
- /**
976
- * Makes only specified properties of an object type optional.
977
- *
978
- * @template T - The base object type
979
- * @template K - The keys to make optional
980
- * @returns An object type with specified properties optional
981
- *
982
- * @example
983
- * ```ts
984
- * type User = { name: string; age: number; email: string };
985
- * type PartialUser = SelectivePartial<User, 'age' | 'email'>;
986
- * // { name: string; age?: number; email?: string }
987
- * ```
988
- */
989
- type SelectivePartial<T, K$1 extends keyof T> = Omit<T, K$1> & Partial<Pick<T, K$1>>;
990
- /**
991
- * Makes all properties of an object type required recursively.
992
- *
993
- * This type traverses through nested objects and arrays, making all properties required.
994
- * Functions and primitives are left unchanged.
995
- *
996
- * @template T - The type to make deeply required
997
- * @returns A type with all properties required recursively
998
- *
999
- * @example
1000
- * ```ts
1001
- * type PartialConfig = {
1002
- * server?: { host?: string; port?: number };
1003
- * };
1004
- *
1005
- * type RequiredConfig = DeepRequired<PartialConfig>;
1006
- * // {
1007
- * // server: { host: string; port: number };
1008
- * // }
1009
- * ```
1010
- */
1011
- 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;
1012
- /**
1013
- * Makes only specified properties of an object type required.
1014
- *
1015
- * @template T - The base object type
1016
- * @template K - The keys to make required
1017
- * @returns An object type with specified properties required
1018
- *
1019
- * @example
1020
- * ```ts
1021
- * type PartialUser = { name?: string; age?: number; email?: string };
1022
- * type RequiredUser = SelectiveRequired<PartialUser, 'name'>;
1023
- * // { name: string; age?: number; email?: string }
1024
- * ```
1025
- */
1026
- type SelectiveRequired<T, K$1 extends keyof T> = Omit<T, K$1> & Required<Pick<T, K$1>>;
1027
- /**
1028
- * Creates a type where all properties are never (useful for excluding types).
1029
- *
1030
- * This can be used to create mutually exclusive types or to exclude certain properties.
1031
- *
1032
- * @template T - The object type to transform
1033
- * @returns An object type with all properties set to never
1034
- *
1035
- * @example
1036
- * ```ts
1037
- * type User = { name: string; age: number };
1038
- * type ExcludedUser = Never<User>; // { name: never; age: never }
1039
- * ```
1040
- */
1041
- type Never<T> = { [K in keyof T]: never };
1042
- /**
1043
- * Makes all properties of an object type nullable recursively.
1044
- *
1045
- * @template T - The type to make nullable
1046
- * @returns A type where all properties can be null
1047
- *
1048
- * @example
1049
- * ```ts
1050
- * type User = { name: string; profile: { age: number } };
1051
- * type NullableUser = Nullable<User>;
1052
- * // { name: string | null; profile: { age: number | null } | null }
1053
- * ```
1054
- */
1055
- type Nullable<T> = T extends object ? { [P in keyof T]: Nullable<T[P]> } : T | null;
1056
- /**
1057
- * Makes all properties of an object type optional (undefined) recursively.
1058
- *
1059
- * @template T - The type to make optional
1060
- * @returns A type where all properties can be undefined
1061
- *
1062
- * @example
1063
- * ```ts
1064
- * type User = { name: string; profile: { age: number } };
1065
- * type OptionalUser = Optional<User>;
1066
- * // { name: string | undefined; profile: { age: number | undefined } | undefined }
1067
- * ```
1068
- */
1069
- type Optional<T> = T extends object ? { [P in keyof T]: Optional<T[P]> } : T | undefined;
1070
- /**
1071
- * Makes all properties of an object type nullish (null or undefined) recursively.
1072
- *
1073
- * @template T - The type to make nullish
1074
- * @returns A type where all properties can be null or undefined
1075
- *
1076
- * @example
1077
- * ```ts
1078
- * type User = { name: string; profile: { age: number } };
1079
- * type NullishUser = Nullish<User>;
1080
- * // { name: string | null | undefined; profile: { age: number | null | undefined } | null | undefined }
1081
- * ```
1082
- */
1083
- type Nullish<T> = T extends object ? { [P in keyof T]: Nullish<T[P]> } : T | null | undefined;
1084
- /**
1085
- * Makes all properties of an object type optional and nullish recursively.
1086
- *
1087
- * This combines optional properties with nullish values.
1088
- *
1089
- * @template T - The type to make maybe
1090
- * @returns A type where all properties are optional and can be null or undefined
1091
- *
1092
- * @example
1093
- * ```ts
1094
- * type User = { name: string; profile: { age: number } };
1095
- * type MaybeUser = Maybe<User>;
1096
- * // { name?: string | null | undefined; profile?: { age?: number | null | undefined } | null | undefined }
1097
- * ```
1098
- */
1099
- type Maybe<T> = T extends object ? { [P in keyof T]?: Nullish<T[P]> } : T | null | undefined;
1100
- /**
1101
- * Makes all properties of an object type readonly recursively.
1102
- *
1103
- * This type traverses through nested objects and arrays, making all properties readonly.
1104
- * Functions and primitives are left unchanged.
1105
- *
1106
- * @template T - The type to make deeply readonly
1107
- * @returns A type with all properties readonly recursively
1108
- *
1109
- * @example
1110
- * ```ts
1111
- * type Config = {
1112
- * server: { host: string; port: number };
1113
- * features: string[];
1114
- * };
1115
- *
1116
- * type ReadonlyConfig = DeepReadonly<Config>;
1117
- * // {
1118
- * // readonly server: { readonly host: string; readonly port: number };
1119
- * // readonly features: readonly string[];
1120
- * // }
1121
- * ```
1122
- */
1123
- 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;
1124
- /**
1125
- * Removes readonly modifier from all properties of an object type recursively.
1126
- *
1127
- * @template T - The readonly type to make mutable
1128
- * @returns A type with all readonly modifiers removed
1129
- *
1130
- * @example
1131
- * ```ts
1132
- * type ReadonlyUser = { readonly name: string; readonly profile: { readonly age: number } };
1133
- * type MutableUser = Mutable<ReadonlyUser>;
1134
- * // { name: string; profile: { age: number } }
1135
- * ```
1136
- */
1137
- type Mutable<T> = { -readonly [P in keyof T]: T[P] };
1138
- /**
1139
- * Extracts keys of an object type that have values of a specific type.
1140
- *
1141
- * @template T - The object type to search
1142
- * @template U - The value type to match
1143
- * @returns A union of keys whose values match the specified type
1144
- *
1145
- * @example
1146
- * ```ts
1147
- * type User = { name: string; age: number; active: boolean };
1148
- * type StringKeys = KeysOfType<User, string>; // 'name'
1149
- * type NumberKeys = KeysOfType<User, number>; // 'age'
1150
- * ```
1151
- */
1152
- type KeysOfType<T, U$1> = { [K in keyof T]: T[K] extends U$1 ? K : never }[keyof T];
1153
- /**
1154
- * Omits properties from an object type that have values of a specific type.
1155
- *
1156
- * @template T - The object type to filter
1157
- * @template U - The value type to exclude
1158
- * @returns An object type without properties of the specified value type
1159
- *
1160
- * @example
1161
- * ```ts
1162
- * type Mixed = { name: string; age: number; active: boolean };
1163
- * type WithoutStrings = OmitByType<Mixed, string>; // { age: number; active: boolean }
1164
- * ```
1165
- */
1166
- type OmitByType<T, U$1> = { [K in keyof T as T[K] extends U$1 ? never : K]: T[K] };
1167
- /**
1168
- * Makes specified properties required while keeping others as-is.
1169
- *
1170
- * @template T - The base object type
1171
- * @template K - The keys to make required
1172
- * @returns An object type with specified properties required
1173
- *
1174
- * @example
1175
- * ```ts
1176
- * type PartialUser = { name?: string; age?: number; email?: string };
1177
- * type RequiredNameUser = RequiredKeys<PartialUser, 'name'>;
1178
- * // { name: string; age?: number; email?: string }
1179
- * ```
1180
- */
1181
- type RequiredKeys<T, K$1 extends keyof T> = Omit<T, K$1> & Required<Pick<T, K$1>>;
1182
- /**
1183
- * Computes the symmetric difference between two object types.
1184
- *
1185
- * Properties that exist in either T or U but not in both.
1186
- *
1187
- * @template T - First object type
1188
- * @template U - Second object type
1189
- * @returns Properties unique to T or U
1190
- *
1191
- * @example
1192
- * ```ts
1193
- * type A = { x: number; y: string };
1194
- * type B = { y: string; z: boolean };
1195
- * type DiffAB = Diff<A, B>; // { x: number; z: boolean }
1196
- * ```
1197
- */
1198
- type Diff<T, U$1> = Omit<T, keyof U$1> & Omit<U$1, keyof T>;
1199
- /**
1200
- * Computes the intersection of two object types (properties present in both).
1201
- *
1202
- * @template T - First object type
1203
- * @template U - Second object type
1204
- * @returns Properties that exist in both T and U
1205
- *
1206
- * @example
1207
- * ```ts
1208
- * type A = { x: number; y: string };
1209
- * type B = { y: string; z: boolean };
1210
- * type IntersectionAB = Intersection<A, B>; // { y: string }
1211
- * ```
1212
- */
1213
- type Intersection<T extends object, U$1 extends object> = Pick<T, Extract<keyof T, keyof U$1> & Extract<keyof U$1, keyof T>>;
1214
- /**
1215
- * Merges two object types, combining their properties.
1216
- *
1217
- * @template T - First object type
1218
- * @template U - Second object type
1219
- * @returns A merged object type with properties from both
1220
- *
1221
- * @example
1222
- * ```ts
1223
- * type A = { x: number; y: string };
1224
- * type B = { y: boolean; z: string };
1225
- * type Merged = Merge<A, B>; // { x: number; y: boolean; z: string }
1226
- * ```
1227
- */
1228
- 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>;
1229
- /**
1230
- * Subtracts properties of one object type from another.
1231
- *
1232
- * @template T - The object type to subtract from
1233
- * @template U - The object type whose properties to subtract
1234
- * @returns T without properties that exist in U
1235
- *
1236
- * @example
1237
- * ```ts
1238
- * type A = { x: number; y: string; z: boolean };
1239
- * type B = { y: string };
1240
- * type Subtracted = Substract<A, B>; // { x: number; z: boolean }
1241
- * ```
1242
- */
1243
- type Substract<T extends object, U$1 extends object> = Omit<T, keyof U$1>;
1244
- /**
1245
- * Represents either all properties present or none of them.
1246
- *
1247
- * Useful for creating mutually exclusive configurations.
1248
- *
1249
- * @template T - The object type
1250
- * @returns Either the full object or an empty object with optional properties
1251
- *
1252
- * @example
1253
- * ```ts
1254
- * type Config = { host: string; port: number };
1255
- * type AllOrNoneConfig = AllOrNone<Config>;
1256
- * // { host: string; port: number } | {}
1257
- * ```
1258
- */
1259
- type AllOrNone<T> = T | { [P in keyof T]?: never };
1260
- /**
1261
- * Represents exactly one property from an object type being present.
1262
- *
1263
- * Useful for creating discriminated unions or mutually exclusive options.
1264
- *
1265
- * @template T - The object type
1266
- * @returns A union where only one property is present at a time
1267
- *
1268
- * @example
1269
- * ```ts
1270
- * type Action = { type: 'create'; payload: string } | { type: 'update'; id: number };
1271
- * type OneAction = OneOf<Action>;
1272
- * // { type: 'create'; payload: string } | { type: 'update'; id: number }
1273
- * ```
1274
- */
1275
- type OneOf<T> = { [K in keyof T]: Pick<T, K> }[keyof T];
1276
- /**
1277
- * Represents exactly two properties from an object type being present.
1278
- *
1279
- * @template T - The object type
1280
- * @returns A union where exactly two properties are present at a time
1281
- *
1282
- * @example
1283
- * ```ts
1284
- * type Config = { a: number; b: string; c: boolean };
1285
- * type TwoConfig = TwoOf<Config>;
1286
- * // { a: number; b: string } | { a: number; c: boolean } | { b: string; c: boolean }
1287
- * ```
1288
- */
1289
- type TwoOf<T> = { [K in keyof T]: { [L in Exclude<keyof T, K>]: Pick<T, K | L> }[Exclude<keyof T, K>] }[keyof T];
1290
- /**
1291
- * Prettifies a complex type by expanding it for better readability in tooltips.
1292
- *
1293
- * This type doesn't change the runtime type but helps with IntelliSense display.
1294
- *
1295
- * @template T - The type to prettify
1296
- * @returns The same type but expanded for better readability
1297
- *
1298
- * @example
1299
- * ```ts
1300
- * type Complex = { a: string } & { b: number };
1301
- * type PrettyComplex = Prettify<Complex>; // Shows as { a: string; b: number }
1302
- * ```
1303
- */
1304
- type Prettify<T> = T extends infer U ? U extends object ? { [K in keyof U]: U[K] } & {} : U : never;
1305
- /**
1306
- * Extracts all nested keys of an object type as dot-separated strings.
1307
- *
1308
- * @template ObjectType - The object type to extract nested keys from
1309
- * @template IgnoreKeys - Keys to ignore during extraction
1310
- * @returns A union of dot-separated string paths
1311
- *
1312
- * @example
1313
- * ```ts
1314
- * type User = {
1315
- * name: string;
1316
- * profile: { age: number; address: { city: string } };
1317
- * tags: string[];
1318
- * };
1319
- *
1320
- * type UserPaths = NestedKeyOf<User>;
1321
- * // 'name' | 'profile' | 'profile.age' | 'profile.address' | 'profile.address.city' | 'tags'
1322
- * ```
1323
- */
1324
- 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];
1325
- /**
1326
- * Creates a type that excludes properties present in another type.
1327
- *
1328
- * This is useful for creating mutually exclusive types.
1329
- *
1330
- * @template T - The base type
1331
- * @template U - The type whose properties to exclude
1332
- * @returns A type with properties from T that are not in U
1333
- *
1334
- * @example
1335
- * ```ts
1336
- * type A = { x: number; y: string };
1337
- * type B = { y: string };
1338
- * type WithoutB = Without<A, B>; // { x?: never }
1339
- * ```
1340
- */
1341
- type Without<T, U$1> = { [P in Exclude<keyof T, keyof U$1>]?: never };
1342
- //#endregion
1343
- //#region src/types/gates.d.ts
1344
- type BUFFER<T> = T;
1345
- type IMPLIES<T, U$1> = T extends U$1 ? true : false;
1346
- 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;
1347
- type XNOR_Binary<T, U$1> = (T & U$1) | (Without<T, U$1> & Without<U$1, T>);
1348
- /**
1349
- * Computes a type-level AND (all must true) for a tuple of types.
1350
- *
1351
- * Truth table for 3 arguments:
1352
- *
1353
- * A B C = AND
1354
- * 1 1 1 = 1
1355
- * 1 1 0 = 0
1356
- * 1 0 1 = 0
1357
- * 1 0 0 = 0
1358
- * 0 1 1 = 0
1359
- * 0 1 0 = 0
1360
- * 0 0 1 = 0
1361
- * 0 0 0 = 0
1362
- *
1363
- * @template T - Tuple of boolean-like types (1/0)
1364
- */
1365
- type AND<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F & AND<R> : F : unknown;
1366
- /**
1367
- * Computes a type-level OR (At least one) for a tuple of types.
1368
- *
1369
- * Truth table for 3 arguments:
1370
- *
1371
- * A B C = OR
1372
- * 1 1 1 = 1
1373
- * 1 1 0 = 1
1374
- * 1 0 1 = 1
1375
- * 1 0 0 = 1
1376
- * 0 1 1 = 1
1377
- * 0 1 0 = 1
1378
- * 0 0 1 = 1
1379
- * 0 0 0 = 0
1380
- *
1381
- * @template T - Tuple of boolean-like types (1/0)
1382
- */
1383
- type OR<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F | OR<R> : F : never;
1384
- /**
1385
- * Computes a type-level XOR (only one/odd) for a tuple of types.
1386
- *
1387
- * Truth table for 3 arguments:
1388
- *
1389
- * A B C = XOR
1390
- * 1 1 1 = 1
1391
- * 1 1 0 = 0
1392
- * 1 0 1 = 0
1393
- * 1 0 0 = 1
1394
- * 0 1 1 = 0
1395
- * 0 1 0 = 1
1396
- * 0 0 1 = 1
1397
- * 0 0 0 = 0
1398
- *
1399
- * @template T - Tuple of boolean-like types (1/0)
1400
- */
1401
- 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;
1402
- /**
1403
- * Computes a type-level XNOR (All or None true) for a tuple of types.
1404
- *
1405
- * Truth table for 3 arguments:
1406
- *
1407
- * A B C = XNOR
1408
- * 1 1 1 = 0
1409
- * 1 1 0 = 1
1410
- * 1 0 1 = 1
1411
- * 1 0 0 = 0
1412
- * 0 1 1 = 1
1413
- * 0 1 0 = 0
1414
- * 0 0 1 = 0
1415
- * 0 0 0 = 1
1416
- *
1417
- * @template T - Tuple of boolean-like types (1/0)
1418
- */
1419
- 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;
1420
- /**
1421
- * Computes a type-level NOT for a tuple of types.
1422
- *
1423
- * Truth table for 3 arguments:
1424
- *
1425
- * A B C = NOT
1426
- * 1 1 1 = 0
1427
- * 1 1 0 = 0
1428
- * 1 0 1 = 0
1429
- * 1 0 0 = 0
1430
- * 0 1 1 = 0
1431
- * 0 1 0 = 0
1432
- * 0 0 1 = 0
1433
- * 0 0 0 = 1
1434
- *
1435
- * @template T - Tuple of boolean-like types (1/0)
1436
- */
1437
- type NOT<T> = { [P in keyof T]?: never };
1438
- /**
1439
- * Computes a type-level NAND for a tuple of types.
1440
- *
1441
- * Truth table for 3 arguments:
1442
- *
1443
- * A B C = NAND
1444
- * 1 1 1 = 0
1445
- * 1 1 0 = 1
1446
- * 1 0 1 = 1
1447
- * 1 0 0 = 1
1448
- * 0 1 1 = 1
1449
- * 0 1 0 = 1
1450
- * 0 0 1 = 1
1451
- * 0 0 0 = 1
1452
- *
1453
- * @template T - Tuple of boolean-like types (1/0)
1454
- */
1455
- type NAND<T extends any[]> = NOT<AND<T>>;
1456
- /**
1457
- * Computes a type-level NOR for a tuple of types.
1458
- *
1459
- * Truth table for 3 arguments:
1460
- *
1461
- * A B C = NOR
1462
- * 1 1 1 = 0
1463
- * 1 1 0 = 0
1464
- * 1 0 1 = 0
1465
- * 1 0 0 = 0
1466
- * 0 1 1 = 0
1467
- * 0 1 0 = 0
1468
- * 0 0 1 = 0
1469
- * 0 0 0 = 1
1470
- *
1471
- * @template T - Tuple of boolean-like types (1/0)
1472
- */
1473
- type NOR<T extends any[]> = NOT<OR<T>>;
1474
- //#endregion
1475
- //#region src/types/guards.d.ts
1476
- /**
1477
- * Represents primitive JavaScript types including null and undefined.
1478
- */
1479
- type Primitive = string | number | bigint | boolean | symbol | null | undefined;
1480
- /**
1481
- * Represents all falsy values in JavaScript.
1482
- */
1483
- type Falsy = false | '' | 0 | null | undefined;
1484
- /**
1485
- * Type guard that checks if a value is falsy.
1486
- *
1487
- * @param val - The value to check
1488
- * @returns True if the value is falsy, false otherwise
1489
- *
1490
- * @example
1491
- * if (isFalsy(value)) {
1492
- * console.log('Value is falsy');
1493
- * }
1494
- */
1495
- declare const isFalsy: (val: unknown) => val is Falsy;
1496
- /**
1497
- * Type guard that checks if a value is null or undefined.
1498
- *
1499
- * @param val - The value to check
1500
- * @returns True if the value is null or undefined, false otherwise
1501
- *
1502
- * @example
1503
- * if (isNullish(value)) {
1504
- * console.log('Value is null or undefined');
1505
- * }
1506
- */
1507
- declare const isNullish: (val: unknown) => val is null | undefined;
1508
- /**
1509
- * Type guard that checks if a value is a primitive type.
1510
- *
1511
- * @param val - The value to check
1512
- * @returns True if the value is a primitive, false otherwise
1513
- *
1514
- * @example
1515
- * if (isPrimitive(value)) {
1516
- * console.log('Value is a primitive type');
1517
- * }
1518
- */
1519
- declare const isPrimitive: (val: unknown) => val is Primitive;
1520
- /**
1521
- * Type guard that checks if a value is a plain object (not an array, function, etc.).
1522
- *
1523
- * @param value - The value to check
1524
- * @returns True if the value is a plain object, false otherwise
1525
- *
1526
- * @example
1527
- * if (isPlainObject(value)) {
1528
- * console.log('Value is a plain object');
1529
- * }
1530
- */
1531
- declare function isPlainObject(value: unknown): value is Record<string, any>;
1532
- //#endregion
1533
- export { AND, AllOrNone, BUFFER, DeepMergeOptions, DeepPartial, DeepReadonly, DeepRequired, Diff, Falsy, IMPLIES, Intersection, Keys, KeysOfType, Maybe, Merge, MergeRefs, 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, cleanSrc, cn, convertToNormalCase, convertToSlug, copyToClipboard, debounce, deepmerge, deleteClientSideCookie, escapeRegExp, extendProps, getClientSideCookie, getObjectValue, goToClientSideHash, hasClientSideCookie, hydrate, isFalsy, isLinkActive, isNavActive, isNullish, isPlainObject, isPrimitive, isSSR, mergeRefs, normalizeText, poll, printf, schedule, scrollTo, setClientSideCookie, shield, sleep, svgToBase64, throttle, workerize };
295
+ export { MergeRefs, cleanSrc, cn, copyToClipboard, deleteClientSideCookie, getClientSideCookie, goToClientSideHash, hasClientSideCookie, isLinkActive, isNavActive, isSSR, mergeRefs, scrollTo, setClientSideCookie, svgToBase64, workerize };