@sohanemon/utils 6.4.7 → 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,421 +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. Also handles nullable types.
279
- *
280
- * @template T The base object or function type (can be null/undefined)
281
- * @template P The additional properties type
282
- *
283
- * @param base - The object or function to extend (can be null/undefined)
284
- * @param props - An object containing properties to attach
285
- *
286
- * @returns The same object/function, augmented with the given properties, or the original value if null/undefined
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
- * // Handle nullable types (e.g., Supabase Session | null)
316
- * const session: Session | null = getSession();
317
- * const extendedSession = extendProps(session, { customProp: 'value' });
318
- * // extendedSession is (Session & { customProp: string }) | null
319
- * ```
320
- */
321
- declare function extendProps<T, P$1 extends object>(base: T, props: P$1): T extends null | undefined ? T : T & P$1;
322
- //#endregion
323
- //#region src/functions/poll.d.ts
324
- /**
325
- * Repeatedly polls an async `cond` function UNTIL it returns a TRUTHY value,
326
- * or until the operation times out or is aborted.
327
- *
328
- * Designed for waiting on async jobs, external state, or delayed availability.
329
- *
330
- * @template T The type of the successful result.
331
- *
332
- * @param cond
333
- * A function returning a Promise that resolves to:
334
- * - a truthy value `T` → stop polling and return it
335
- * - falsy/null/undefined → continue polling
336
- *
337
- * @param options
338
- * Configuration options:
339
- * - `interval` (number) — Time between polls in ms (default: 5000 ms)
340
- * - `timeout` (number) — Max total duration before failing (default: 5 min)
341
- * - `jitter` (boolean) — Add small random offset (±10%) to intervals to avoid sync bursts (default: true)
342
- * - `signal` (AbortSignal) — Optional abort signal to cancel polling
343
- *
344
- * @returns
345
- * Resolves with the truthy value `T` when successful.
346
- * Throws `AbortError` if aborted
347
- *
348
- * @example
349
- * ```ts
350
- * // Poll for job completion
351
- * const job = await poll(async () => {
352
- * const status = await getJobStatus();
353
- * return status === 'done' ? status : null;
354
- * }, { interval: 3000, timeout: 60000 });
355
- * ```
356
- *
357
- * @example
358
- * ```ts
359
- * // Wait for API endpoint to be ready
360
- * const apiReady = await poll(async () => {
361
- * try {
362
- * await fetch('/api/health');
363
- * return true;
364
- * } catch {
365
- * return null;
366
- * }
367
- * }, { interval: 1000, timeout: 30000 });
368
- * ```
369
- *
370
- * @example
371
- * ```ts
372
- * // Poll with abort signal for cancellation
373
- * const controller = new AbortController();
374
- * setTimeout(() => controller.abort(), 10000); // Cancel after 10s
375
- *
376
- * try {
377
- * const result = await poll(
378
- * () => checkExternalService(),
379
- * { interval: 2000, signal: controller.signal }
380
- * );
381
- * } catch (err) {
382
- * if (err.name === 'AbortError') {
383
- * console.log('Polling was cancelled');
384
- * }
385
- * }
386
- * ```
387
- *
388
- * @example
389
- * ```ts
390
- * // Poll for user action completion
391
- * const userConfirmed = await poll(async () => {
392
- * const confirmations = await getPendingConfirmations();
393
- * return confirmations.length > 0 ? confirmations[0] : null;
394
- * }, { interval: 5000, timeout: 300000 }); // 5 min timeout
395
- * ```
396
- */
397
- declare function poll<T>(cond: () => Promise<T | null | false | undefined>, {
398
- interval,
399
- timeout,
400
- jitter,
401
- signal
402
- }?: Partial<{
403
- interval: number;
404
- timeout: number;
405
- signal: AbortSignal;
406
- jitter: boolean;
407
- }>): Promise<T>;
408
- //#endregion
409
- //#region src/functions/shield.d.ts
410
- /**
411
- * A helper to run sync or async operations safely without try/catch.
412
- *
413
- * Returns a tuple `[error, data]`:
414
- * - `error`: the thrown error (if any), otherwise `null`
415
- * - `data`: the resolved value (if successful), otherwise `null`
416
- *
417
- * @example
418
- * ```ts
419
- * // Synchronous error handling
420
- * const [err, value] = shield(() => {
421
- * if (Math.random() > 0.5) throw new Error('Random failure');
422
- * return 'success';
423
- * });
424
- * if (err) {
425
- * console.error('Operation failed:', err);
426
- * } else {
427
- * console.log('Result:', value);
428
- * }
429
- *
430
- * // Asynchronous error handling
431
- * const [asyncErr, result] = await shield(async () => {
432
- * const response = await fetch('/api/data');
433
- * if (!response.ok) throw new Error('API error');
434
- * return response.json();
435
- * });
436
- * if (asyncErr) {
437
- * console.error('API call failed:', asyncErr);
438
- * } else {
439
- * processData(result);
440
- * }
441
- *
442
- * // API calls with fallbacks
443
- * const [fetchErr, data] = await shield(fetchUserData(userId));
444
- * const userData = fetchErr ? getCachedUserData(userId) : data;
445
- *
446
- * // File operations
447
- * const [fileErr, content] = shield(() => readFileSync('config.json'));
448
- * if (fileErr) {
449
- * console.warn('Could not read config, using defaults');
450
- * return defaultConfig;
451
- * }
452
- * ```
453
- *
454
- * @example
455
- * ```ts
456
- * // In async functions
457
- * async function safeApiCall() {
458
- * const [err, result] = await shield(callExternalAPI());
459
- * if (err) {
460
- * await logError(err);
461
- * return null;
462
- * }
463
- * return result;
464
- * }
465
- *
466
- * // In event handlers
467
- * function handleSubmit(formData) {
468
- * const [validationErr, validatedData] = shield(() => validateForm(formData));
469
- * if (validationErr) {
470
- * showValidationError(validationErr);
471
- * return;
472
- * }
473
- * submitData(validatedData);
474
- * }
475
- * ```
476
- */
477
- declare function shield<T, E = Error>(operation: Promise<T>): Promise<[E | null, T | null]>;
478
- declare function shield<T, E = Error>(operation: () => T): [E | null, T | null];
479
- //#endregion
480
65
  //#region src/functions/utils.d.ts
481
66
  /**
482
67
  * Utility to merge class names with Tailwind CSS and additional custom merging logic.
@@ -496,8 +81,8 @@ declare function cn(...inputs: ClassValue[]): string;
496
81
  *
497
82
  * Determines if a navigation link is active based on the current path.
498
83
  *
499
- * @param href - The target URL.
500
- * @param path - The current browser path.
84
+ * @param href - The target URL.
85
+ * @param path - The current browser path.
501
86
  * @returns - True if the navigation is active, false otherwise.
502
87
  *
503
88
  * @example
@@ -598,36 +183,6 @@ declare const scrollTo: (containerSelector: string | React.RefObject<HTMLDivElem
598
183
  * ```
599
184
  */
600
185
  declare const copyToClipboard: (value: string, onSuccess?: () => void) => void;
601
- /**
602
- * Converts various case styles (camelCase, PascalCase, kebab-case, snake_case) into readable normal case.
603
- *
604
- * Transforms technical naming conventions into human-readable titles by:
605
- * - Adding spaces between words
606
- * - Capitalizing the first letter of each word
607
- * - Handling common separators (-, _, camelCase boundaries)
608
- *
609
- * @param inputString - The string to convert (supports camelCase, PascalCase, kebab-case, snake_case).
610
- * @returns The converted string in normal case (title case).
611
- *
612
- * @example
613
- * ```ts
614
- * convertToNormalCase('camelCase') // 'Camel Case'
615
- * convertToNormalCase('kebab-case') // 'Kebab Case'
616
- * convertToNormalCase('snake_case') // 'Snake Case'
617
- * convertToNormalCase('PascalCase') // 'Pascal Case'
618
- * ```
619
- */
620
- declare function convertToNormalCase(inputString: string): string;
621
- /**
622
- * Converts a string to a URL-friendly slug by trimming, converting to lowercase,
623
- * replacing diacritics, removing invalid characters, and replacing spaces with hyphens.
624
- * @param {string} [str] - The input string to convert.
625
- * @returns {string} The generated slug.
626
- * @example
627
- * convertToSlug("Hello World!"); // "hello-world"
628
- * convertToSlug("Déjà Vu"); // "deja-vu"
629
- */
630
- declare const convertToSlug: (str: string) => string;
631
186
  /**
632
187
  * Checks if the code is running in a server-side environment.
633
188
  *
@@ -659,154 +214,6 @@ declare const isSSR: boolean;
659
214
  * ```
660
215
  */
661
216
  declare const svgToBase64: (str: string) => string;
662
- /**
663
- * Pauses execution for the specified time.
664
- *
665
- * `signal` allows cancelling the sleep via AbortSignal.
666
- *
667
- * @param time - Time in milliseconds to sleep (default is 1000ms)
668
- * @param signal - Optional AbortSignal to cancel the sleep early
669
- * @returns - A Promise that resolves after the specified time or when aborted
670
- */
671
- declare const sleep: (time?: number, signal?: AbortSignal) => Promise<void>;
672
- type DebouncedFunction<F$1 extends (...args: any[]) => any> = {
673
- (...args: Parameters<F$1>): ReturnType<F$1> | undefined;
674
- readonly isPending: boolean;
675
- };
676
- /**
677
- * Creates a debounced function that delays invoking the provided function until
678
- * after the specified `wait` time has elapsed since the last invocation.
679
- *
680
- * If the `immediate` option is set to `true`, the function will be invoked immediately
681
- * on the leading edge of the wait interval. Subsequent calls during the wait interval
682
- * will reset the timer but not invoke the function until the interval elapses again.
683
- *
684
- * The returned function includes the `isPending` property to check if the debounce
685
- * timer is currently active.
686
- *
687
- * @typeParam F - The type of the function to debounce.
688
- *
689
- * @param function_ - The function to debounce.
690
- * @param wait - The number of milliseconds to delay (default is 100ms).
691
- * @param options - An optional object with the following properties:
692
- * - `immediate` (boolean): If `true`, invokes the function on the leading edge
693
- * of the wait interval instead of the trailing edge.
694
- *
695
- * @returns A debounced version of the provided function, enhanced with the `isPending` property.
696
- *
697
- * @throws {TypeError} If the first parameter is not a function.
698
- * @throws {RangeError} If the `wait` parameter is negative.
699
- *
700
- * @example
701
- * ```ts
702
- * // Basic debouncing
703
- * const log = debounce((message: string) => console.log(message), 200);
704
- * log('Hello'); // Logs "Hello" after 200ms if no other call is made.
705
- * console.log(log.isPending); // true if the timer is active.
706
- *
707
- * // Immediate execution
708
- * const save = debounce(() => saveToServer(), 500, { immediate: true });
709
- * save(); // Executes immediately, then waits 500ms for subsequent calls
710
- *
711
- * // Check pending state
712
- * const debouncedSearch = debounce(searchAPI, 300);
713
- * debouncedSearch('query');
714
- * if (debouncedSearch.isPending) {
715
- * showLoadingIndicator();
716
- * }
717
- * ```
718
- */
719
- declare function debounce<F$1 extends (...args: any[]) => any>(function_: F$1, wait?: number, options?: {
720
- immediate: boolean;
721
- }): DebouncedFunction<F$1>;
722
- type ThrottledFunction<F$1 extends (...args: any[]) => any> = {
723
- (...args: Parameters<F$1>): ReturnType<F$1> | undefined;
724
- readonly isPending: boolean;
725
- };
726
- /**
727
- * Creates a throttled function that invokes the provided function at most once
728
- * every `wait` milliseconds.
729
- *
730
- * If the `leading` option is set to `true`, the function will be invoked immediately
731
- * on the leading edge of the throttle interval. If the `trailing` option is set to `true`,
732
- * the function will also be invoked at the end of the throttle interval if additional
733
- * calls were made during the interval.
734
- *
735
- * The returned function includes the `isPending` property to check if the throttle
736
- * timer is currently active.
737
- *
738
- * @typeParam F - The type of the function to throttle.
739
- *
740
- * @param function_ - The function to throttle.
741
- * @param wait - The number of milliseconds to wait between invocations (default is 100ms).
742
- * @param options - An optional object with the following properties:
743
- * - `leading` (boolean): If `true`, invokes the function on the leading edge of the interval.
744
- * - `trailing` (boolean): If `true`, invokes the function on the trailing edge of the interval.
745
- *
746
- * @returns A throttled version of the provided function, enhanced with the `isPending` property.
747
- *
748
- * @throws {TypeError} If the first parameter is not a function.
749
- * @throws {RangeError} If the `wait` parameter is negative.
750
- *
751
- * @example
752
- * ```ts
753
- * // Basic throttling (leading edge by default)
754
- * const log = throttle((message: string) => console.log(message), 200);
755
- * log('Hello'); // Logs "Hello" immediately
756
- * log('World'); // Ignored for 200ms
757
- * console.log(log.isPending); // true if within throttle window
758
- *
759
- * // Trailing edge only
760
- * const trailingLog = throttle(() => console.log('trailing'), 200, {
761
- * leading: false,
762
- * trailing: true
763
- * });
764
- * trailingLog(); // No immediate execution
765
- * // After 200ms: logs "trailing"
766
- *
767
- * // Both edges
768
- * const bothLog = throttle(() => console.log('both'), 200, {
769
- * leading: true,
770
- * trailing: true
771
- * });
772
- * bothLog(); // Immediate execution
773
- * // After 200ms: executes again if called during window
774
- * ```
775
- */
776
- declare function throttle<F$1 extends (...args: any[]) => any>(function_: F$1, wait?: number, options?: {
777
- leading?: boolean;
778
- trailing?: boolean;
779
- }): ThrottledFunction<F$1>;
780
- /**
781
- * Formats a string by replacing each '%s' placeholder with the corresponding argument.
782
- *
783
- * Mimics the basic behavior of C's printf for %s substitution. Supports both
784
- * variadic arguments and array-based argument passing. Extra placeholders
785
- * are left as-is, missing arguments result in empty strings.
786
- *
787
- * @param format - The format string containing '%s' placeholders.
788
- * @param args - The values to substitute, either as separate arguments or a single array.
789
- * @returns The formatted string with placeholders replaced by arguments.
790
- *
791
- * @example
792
- * ```ts
793
- * // Basic usage with separate arguments
794
- * printf("%s love %s", "I", "Bangladesh") // "I love Bangladesh"
795
- *
796
- * // Using array of arguments
797
- * printf("%s love %s", ["I", "Bangladesh"]) // "I love Bangladesh"
798
- *
799
- * // Extra placeholders remain unchanged
800
- * printf("%s %s %s", "Hello", "World") // "Hello World %s"
801
- *
802
- * // Missing arguments become empty strings
803
- * printf("%s and %s", "this") // "this and "
804
- *
805
- * // Multiple occurrences
806
- * printf("%s %s %s", "repeat", "repeat", "repeat") // "repeat repeat repeat"
807
- * ```
808
- */
809
- declare function printf(format: string, ...args: unknown[]): string;
810
217
  /**
811
218
  * Merges multiple refs into a single ref callback.
812
219
  *
@@ -846,47 +253,6 @@ declare const mergeRefs: MergeRefs;
846
253
  * ```
847
254
  */
848
255
  declare function goToClientSideHash(id: string, opts?: ScrollIntoViewOptions): void;
849
- /**
850
- * Escapes a string for use in a regular expression.
851
- *
852
- * @param str - The string to escape
853
- * @returns - The escaped string safe for use in RegExp constructor
854
- *
855
- * @example
856
- * ```ts
857
- * const escapedString = escapeRegExp('Hello, world!');
858
- * // escapedString === 'Hello\\, world!'
859
- *
860
- * const regex = new RegExp(escapeRegExp(userInput));
861
- * ```
862
- */
863
- declare function escapeRegExp(str: string): string;
864
- /**
865
- * Normalizes a string by:
866
- * - Applying Unicode normalization (NFC)
867
- * - Optionally removing diacritic marks (accents)
868
- * - Optionally trimming leading/trailing non-alphanumeric characters
869
- * - Optionally converting to lowercase
870
- *
871
- * @param str - The string to normalize
872
- * @param options - Normalization options
873
- * @param options.lowercase - Whether to convert the result to lowercase (default: true)
874
- * @param options.removeAccents - Whether to remove diacritic marks like accents (default: true)
875
- * @param options.removeNonAlphanumeric - Whether to trim non-alphanumeric characters from the edges (default: true)
876
- * @returns The normalized string
877
- *
878
- * @example
879
- * ```ts
880
- * normalizeText('Café') // 'cafe'
881
- * normalizeText(' Hello! ') // 'hello'
882
- * normalizeText('José', { removeAccents: false }) // 'josé'
883
- * ```
884
- */
885
- declare function normalizeText(str?: string | null, options?: {
886
- lowercase?: boolean;
887
- removeAccents?: boolean;
888
- removeNonAlphanumeric?: boolean;
889
- }): string;
890
256
  //#endregion
891
257
  //#region src/functions/worker.d.ts
892
258
  /**
@@ -926,613 +292,4 @@ declare function normalizeText(str?: string | null, options?: {
926
292
  */
927
293
  declare function workerize<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => Promise<ReturnType<T>>;
928
294
  //#endregion
929
- //#region src/types/utilities.d.ts
930
- /**
931
- * Extracts the keys of an object type as a union type.
932
- *
933
- * @template T - The object type to extract keys from
934
- * @returns A union of all keys in the object type
935
- *
936
- * @example
937
- * ```ts
938
- * type User = { name: string; age: number };
939
- * type UserKeys = Keys<User>; // 'name' | 'age'
940
- * ```
941
- */
942
- type Keys<T extends object> = keyof T;
943
- /**
944
- * Extracts the values of an object type as a union type.
945
- *
946
- * @template T - The object type to extract values from
947
- * @returns A union of all values in the object type
948
- *
949
- * @example
950
- * ```ts
951
- * type User = { name: string; age: number };
952
- * type UserValues = Values<User>; // string | number
953
- * ```
954
- */
955
- type Values<T extends object> = T[keyof T];
956
- /**
957
- * Makes all properties of an object type optional recursively.
958
- *
959
- * This type traverses through nested objects and arrays, making all properties optional.
960
- * Functions and primitives are left unchanged.
961
- *
962
- * @template T - The type to make deeply partial
963
- * @returns A type with all properties optional recursively
964
- *
965
- * @example
966
- * ```ts
967
- * type Config = {
968
- * server: { host: string; port: number };
969
- * features: string[];
970
- * };
971
- *
972
- * type PartialConfig = DeepPartial<Config>;
973
- * // {
974
- * // server?: { host?: string; port?: number };
975
- * // features?: string[];
976
- * // }
977
- * ```
978
- */
979
- 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;
980
- /**
981
- * Makes only specified properties of an object type optional.
982
- *
983
- * @template T - The base object type
984
- * @template K - The keys to make optional
985
- * @returns An object type with specified properties optional
986
- *
987
- * @example
988
- * ```ts
989
- * type User = { name: string; age: number; email: string };
990
- * type PartialUser = SelectivePartial<User, 'age' | 'email'>;
991
- * // { name: string; age?: number; email?: string }
992
- * ```
993
- */
994
- type SelectivePartial<T, K$1 extends keyof T> = Omit<T, K$1> & Partial<Pick<T, K$1>>;
995
- /**
996
- * Makes all properties of an object type required recursively.
997
- *
998
- * This type traverses through nested objects and arrays, making all properties required.
999
- * Functions and primitives are left unchanged.
1000
- *
1001
- * @template T - The type to make deeply required
1002
- * @returns A type with all properties required recursively
1003
- *
1004
- * @example
1005
- * ```ts
1006
- * type PartialConfig = {
1007
- * server?: { host?: string; port?: number };
1008
- * };
1009
- *
1010
- * type RequiredConfig = DeepRequired<PartialConfig>;
1011
- * // {
1012
- * // server: { host: string; port: number };
1013
- * // }
1014
- * ```
1015
- */
1016
- 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;
1017
- /**
1018
- * Makes only specified properties of an object type required.
1019
- *
1020
- * @template T - The base object type
1021
- * @template K - The keys to make required
1022
- * @returns An object type with specified properties required
1023
- *
1024
- * @example
1025
- * ```ts
1026
- * type PartialUser = { name?: string; age?: number; email?: string };
1027
- * type RequiredUser = SelectiveRequired<PartialUser, 'name'>;
1028
- * // { name: string; age?: number; email?: string }
1029
- * ```
1030
- */
1031
- type SelectiveRequired<T, K$1 extends keyof T> = Omit<T, K$1> & Required<Pick<T, K$1>>;
1032
- /**
1033
- * Creates a type where all properties are never (useful for excluding types).
1034
- *
1035
- * This can be used to create mutually exclusive types or to exclude certain properties.
1036
- *
1037
- * @template T - The object type to transform
1038
- * @returns An object type with all properties set to never
1039
- *
1040
- * @example
1041
- * ```ts
1042
- * type User = { name: string; age: number };
1043
- * type ExcludedUser = Never<User>; // { name: never; age: never }
1044
- * ```
1045
- */
1046
- type Never<T> = { [K in keyof T]: never };
1047
- /**
1048
- * Makes all properties of an object type nullable recursively.
1049
- *
1050
- * @template T - The type to make nullable
1051
- * @returns A type where all properties can be null
1052
- *
1053
- * @example
1054
- * ```ts
1055
- * type User = { name: string; profile: { age: number } };
1056
- * type NullableUser = Nullable<User>;
1057
- * // { name: string | null; profile: { age: number | null } | null }
1058
- * ```
1059
- */
1060
- type Nullable<T> = T extends object ? { [P in keyof T]: Nullable<T[P]> } : T | null;
1061
- /**
1062
- * Makes all properties of an object type optional (undefined) recursively.
1063
- *
1064
- * @template T - The type to make optional
1065
- * @returns A type where all properties can be undefined
1066
- *
1067
- * @example
1068
- * ```ts
1069
- * type User = { name: string; profile: { age: number } };
1070
- * type OptionalUser = Optional<User>;
1071
- * // { name: string | undefined; profile: { age: number | undefined } | undefined }
1072
- * ```
1073
- */
1074
- type Optional<T> = T extends object ? { [P in keyof T]: Optional<T[P]> } : T | undefined;
1075
- /**
1076
- * Makes all properties of an object type nullish (null or undefined) recursively.
1077
- *
1078
- * @template T - The type to make nullish
1079
- * @returns A type where all properties can be null or undefined
1080
- *
1081
- * @example
1082
- * ```ts
1083
- * type User = { name: string; profile: { age: number } };
1084
- * type NullishUser = Nullish<User>;
1085
- * // { name: string | null | undefined; profile: { age: number | null | undefined } | null | undefined }
1086
- * ```
1087
- */
1088
- type Nullish<T> = T extends object ? { [P in keyof T]: Nullish<T[P]> } : T | null | undefined;
1089
- /**
1090
- * Makes all properties of an object type optional and nullish recursively.
1091
- *
1092
- * This combines optional properties with nullish values.
1093
- *
1094
- * @template T - The type to make maybe
1095
- * @returns A type where all properties are optional and can be null or undefined
1096
- *
1097
- * @example
1098
- * ```ts
1099
- * type User = { name: string; profile: { age: number } };
1100
- * type MaybeUser = Maybe<User>;
1101
- * // { name?: string | null | undefined; profile?: { age?: number | null | undefined } | null | undefined }
1102
- * ```
1103
- */
1104
- type Maybe<T> = T extends object ? { [P in keyof T]?: Nullish<T[P]> } : T | null | undefined;
1105
- /**
1106
- * Makes all properties of an object type readonly recursively.
1107
- *
1108
- * This type traverses through nested objects and arrays, making all properties readonly.
1109
- * Functions and primitives are left unchanged.
1110
- *
1111
- * @template T - The type to make deeply readonly
1112
- * @returns A type with all properties readonly recursively
1113
- *
1114
- * @example
1115
- * ```ts
1116
- * type Config = {
1117
- * server: { host: string; port: number };
1118
- * features: string[];
1119
- * };
1120
- *
1121
- * type ReadonlyConfig = DeepReadonly<Config>;
1122
- * // {
1123
- * // readonly server: { readonly host: string; readonly port: number };
1124
- * // readonly features: readonly string[];
1125
- * // }
1126
- * ```
1127
- */
1128
- 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;
1129
- /**
1130
- * Removes readonly modifier from all properties of an object type recursively.
1131
- *
1132
- * @template T - The readonly type to make mutable
1133
- * @returns A type with all readonly modifiers removed
1134
- *
1135
- * @example
1136
- * ```ts
1137
- * type ReadonlyUser = { readonly name: string; readonly profile: { readonly age: number } };
1138
- * type MutableUser = Mutable<ReadonlyUser>;
1139
- * // { name: string; profile: { age: number } }
1140
- * ```
1141
- */
1142
- type Mutable<T> = { -readonly [P in keyof T]: T[P] };
1143
- /**
1144
- * Extracts keys of an object type that have values of a specific type.
1145
- *
1146
- * @template T - The object type to search
1147
- * @template U - The value type to match
1148
- * @returns A union of keys whose values match the specified type
1149
- *
1150
- * @example
1151
- * ```ts
1152
- * type User = { name: string; age: number; active: boolean };
1153
- * type StringKeys = KeysOfType<User, string>; // 'name'
1154
- * type NumberKeys = KeysOfType<User, number>; // 'age'
1155
- * ```
1156
- */
1157
- type KeysOfType<T, U$1> = { [K in keyof T]: T[K] extends U$1 ? K : never }[keyof T];
1158
- /**
1159
- * Omits properties from an object type that have values of a specific type.
1160
- *
1161
- * @template T - The object type to filter
1162
- * @template U - The value type to exclude
1163
- * @returns An object type without properties of the specified value type
1164
- *
1165
- * @example
1166
- * ```ts
1167
- * type Mixed = { name: string; age: number; active: boolean };
1168
- * type WithoutStrings = OmitByType<Mixed, string>; // { age: number; active: boolean }
1169
- * ```
1170
- */
1171
- type OmitByType<T, U$1> = { [K in keyof T as T[K] extends U$1 ? never : K]: T[K] };
1172
- /**
1173
- * Makes specified properties required while keeping others as-is.
1174
- *
1175
- * @template T - The base object type
1176
- * @template K - The keys to make required
1177
- * @returns An object type with specified properties required
1178
- *
1179
- * @example
1180
- * ```ts
1181
- * type PartialUser = { name?: string; age?: number; email?: string };
1182
- * type RequiredNameUser = RequiredKeys<PartialUser, 'name'>;
1183
- * // { name: string; age?: number; email?: string }
1184
- * ```
1185
- */
1186
- type RequiredKeys<T, K$1 extends keyof T> = Omit<T, K$1> & Required<Pick<T, K$1>>;
1187
- /**
1188
- * Computes the symmetric difference between two object types.
1189
- *
1190
- * Properties that exist in either T or U but not in both.
1191
- *
1192
- * @template T - First object type
1193
- * @template U - Second object type
1194
- * @returns Properties unique to T or U
1195
- *
1196
- * @example
1197
- * ```ts
1198
- * type A = { x: number; y: string };
1199
- * type B = { y: string; z: boolean };
1200
- * type DiffAB = Diff<A, B>; // { x: number; z: boolean }
1201
- * ```
1202
- */
1203
- type Diff<T, U$1> = Omit<T, keyof U$1> & Omit<U$1, keyof T>;
1204
- /**
1205
- * Computes the intersection of two object types (properties present in both).
1206
- *
1207
- * @template T - First object type
1208
- * @template U - Second object type
1209
- * @returns Properties that exist in both T and U
1210
- *
1211
- * @example
1212
- * ```ts
1213
- * type A = { x: number; y: string };
1214
- * type B = { y: string; z: boolean };
1215
- * type IntersectionAB = Intersection<A, B>; // { y: string }
1216
- * ```
1217
- */
1218
- type Intersection<T extends object, U$1 extends object> = Pick<T, Extract<keyof T, keyof U$1> & Extract<keyof U$1, keyof T>>;
1219
- /**
1220
- * Merges two object types, combining their properties.
1221
- *
1222
- * @template T - First object type
1223
- * @template U - Second object type
1224
- * @returns A merged object type with properties from both
1225
- *
1226
- * @example
1227
- * ```ts
1228
- * type A = { x: number; y: string };
1229
- * type B = { y: boolean; z: string };
1230
- * type Merged = Merge<A, B>; // { x: number; y: boolean; z: string }
1231
- * ```
1232
- */
1233
- 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>;
1234
- /**
1235
- * Subtracts properties of one object type from another.
1236
- *
1237
- * @template T - The object type to subtract from
1238
- * @template U - The object type whose properties to subtract
1239
- * @returns T without properties that exist in U
1240
- *
1241
- * @example
1242
- * ```ts
1243
- * type A = { x: number; y: string; z: boolean };
1244
- * type B = { y: string };
1245
- * type Subtracted = Substract<A, B>; // { x: number; z: boolean }
1246
- * ```
1247
- */
1248
- type Substract<T extends object, U$1 extends object> = Omit<T, keyof U$1>;
1249
- /**
1250
- * Represents either all properties present or none of them.
1251
- *
1252
- * Useful for creating mutually exclusive configurations.
1253
- *
1254
- * @template T - The object type
1255
- * @returns Either the full object or an empty object with optional properties
1256
- *
1257
- * @example
1258
- * ```ts
1259
- * type Config = { host: string; port: number };
1260
- * type AllOrNoneConfig = AllOrNone<Config>;
1261
- * // { host: string; port: number } | {}
1262
- * ```
1263
- */
1264
- type AllOrNone<T> = T | { [P in keyof T]?: never };
1265
- /**
1266
- * Represents exactly one property from an object type being present.
1267
- *
1268
- * Useful for creating discriminated unions or mutually exclusive options.
1269
- *
1270
- * @template T - The object type
1271
- * @returns A union where only one property is present at a time
1272
- *
1273
- * @example
1274
- * ```ts
1275
- * type Action = { type: 'create'; payload: string } | { type: 'update'; id: number };
1276
- * type OneAction = OneOf<Action>;
1277
- * // { type: 'create'; payload: string } | { type: 'update'; id: number }
1278
- * ```
1279
- */
1280
- type OneOf<T> = { [K in keyof T]: Pick<T, K> }[keyof T];
1281
- /**
1282
- * Represents exactly two properties from an object type being present.
1283
- *
1284
- * @template T - The object type
1285
- * @returns A union where exactly two properties are present at a time
1286
- *
1287
- * @example
1288
- * ```ts
1289
- * type Config = { a: number; b: string; c: boolean };
1290
- * type TwoConfig = TwoOf<Config>;
1291
- * // { a: number; b: string } | { a: number; c: boolean } | { b: string; c: boolean }
1292
- * ```
1293
- */
1294
- type TwoOf<T> = { [K in keyof T]: { [L in Exclude<keyof T, K>]: Pick<T, K | L> }[Exclude<keyof T, K>] }[keyof T];
1295
- /**
1296
- * Prettifies a complex type by expanding it for better readability in tooltips.
1297
- *
1298
- * This type doesn't change the runtime type but helps with IntelliSense display.
1299
- *
1300
- * @template T - The type to prettify
1301
- * @returns The same type but expanded for better readability
1302
- *
1303
- * @example
1304
- * ```ts
1305
- * type Complex = { a: string } & { b: number };
1306
- * type PrettyComplex = Prettify<Complex>; // Shows as { a: string; b: number }
1307
- * ```
1308
- */
1309
- type Prettify<T> = T extends infer U ? U extends object ? { [K in keyof U]: U[K] } & {} : U : never;
1310
- /**
1311
- * Extracts all nested keys of an object type as dot-separated strings.
1312
- *
1313
- * @template ObjectType - The object type to extract nested keys from
1314
- * @template IgnoreKeys - Keys to ignore during extraction
1315
- * @returns A union of dot-separated string paths
1316
- *
1317
- * @example
1318
- * ```ts
1319
- * type User = {
1320
- * name: string;
1321
- * profile: { age: number; address: { city: string } };
1322
- * tags: string[];
1323
- * };
1324
- *
1325
- * type UserPaths = NestedKeyOf<User>;
1326
- * // 'name' | 'profile' | 'profile.age' | 'profile.address' | 'profile.address.city' | 'tags'
1327
- * ```
1328
- */
1329
- 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];
1330
- /**
1331
- * Creates a type that excludes properties present in another type.
1332
- *
1333
- * This is useful for creating mutually exclusive types.
1334
- *
1335
- * @template T - The base type
1336
- * @template U - The type whose properties to exclude
1337
- * @returns A type with properties from T that are not in U
1338
- *
1339
- * @example
1340
- * ```ts
1341
- * type A = { x: number; y: string };
1342
- * type B = { y: string };
1343
- * type WithoutB = Without<A, B>; // { x?: never }
1344
- * ```
1345
- */
1346
- type Without<T, U$1> = { [P in Exclude<keyof T, keyof U$1>]?: never };
1347
- //#endregion
1348
- //#region src/types/gates.d.ts
1349
- type BUFFER<T> = T;
1350
- type IMPLIES<T, U$1> = T extends U$1 ? true : false;
1351
- 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;
1352
- type XNOR_Binary<T, U$1> = (T & U$1) | (Without<T, U$1> & Without<U$1, T>);
1353
- /**
1354
- * Computes a type-level AND (all must true) for a tuple of types.
1355
- *
1356
- * Truth table for 3 arguments:
1357
- *
1358
- * A B C = AND
1359
- * 1 1 1 = 1
1360
- * 1 1 0 = 0
1361
- * 1 0 1 = 0
1362
- * 1 0 0 = 0
1363
- * 0 1 1 = 0
1364
- * 0 1 0 = 0
1365
- * 0 0 1 = 0
1366
- * 0 0 0 = 0
1367
- *
1368
- * @template T - Tuple of boolean-like types (1/0)
1369
- */
1370
- type AND<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F & AND<R> : F : unknown;
1371
- /**
1372
- * Computes a type-level OR (At least one) for a tuple of types.
1373
- *
1374
- * Truth table for 3 arguments:
1375
- *
1376
- * A B C = OR
1377
- * 1 1 1 = 1
1378
- * 1 1 0 = 1
1379
- * 1 0 1 = 1
1380
- * 1 0 0 = 1
1381
- * 0 1 1 = 1
1382
- * 0 1 0 = 1
1383
- * 0 0 1 = 1
1384
- * 0 0 0 = 0
1385
- *
1386
- * @template T - Tuple of boolean-like types (1/0)
1387
- */
1388
- type OR<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F | OR<R> : F : never;
1389
- /**
1390
- * Computes a type-level XOR (only one/odd) for a tuple of types.
1391
- *
1392
- * Truth table for 3 arguments:
1393
- *
1394
- * A B C = XOR
1395
- * 1 1 1 = 1
1396
- * 1 1 0 = 0
1397
- * 1 0 1 = 0
1398
- * 1 0 0 = 1
1399
- * 0 1 1 = 0
1400
- * 0 1 0 = 1
1401
- * 0 0 1 = 1
1402
- * 0 0 0 = 0
1403
- *
1404
- * @template T - Tuple of boolean-like types (1/0)
1405
- */
1406
- 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;
1407
- /**
1408
- * Computes a type-level XNOR (All or None true) for a tuple of types.
1409
- *
1410
- * Truth table for 3 arguments:
1411
- *
1412
- * A B C = XNOR
1413
- * 1 1 1 = 0
1414
- * 1 1 0 = 1
1415
- * 1 0 1 = 1
1416
- * 1 0 0 = 0
1417
- * 0 1 1 = 1
1418
- * 0 1 0 = 0
1419
- * 0 0 1 = 0
1420
- * 0 0 0 = 1
1421
- *
1422
- * @template T - Tuple of boolean-like types (1/0)
1423
- */
1424
- 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;
1425
- /**
1426
- * Computes a type-level NOT for a tuple of types.
1427
- *
1428
- * Truth table for 3 arguments:
1429
- *
1430
- * A B C = NOT
1431
- * 1 1 1 = 0
1432
- * 1 1 0 = 0
1433
- * 1 0 1 = 0
1434
- * 1 0 0 = 0
1435
- * 0 1 1 = 0
1436
- * 0 1 0 = 0
1437
- * 0 0 1 = 0
1438
- * 0 0 0 = 1
1439
- *
1440
- * @template T - Tuple of boolean-like types (1/0)
1441
- */
1442
- type NOT<T> = { [P in keyof T]?: never };
1443
- /**
1444
- * Computes a type-level NAND for a tuple of types.
1445
- *
1446
- * Truth table for 3 arguments:
1447
- *
1448
- * A B C = NAND
1449
- * 1 1 1 = 0
1450
- * 1 1 0 = 1
1451
- * 1 0 1 = 1
1452
- * 1 0 0 = 1
1453
- * 0 1 1 = 1
1454
- * 0 1 0 = 1
1455
- * 0 0 1 = 1
1456
- * 0 0 0 = 1
1457
- *
1458
- * @template T - Tuple of boolean-like types (1/0)
1459
- */
1460
- type NAND<T extends any[]> = NOT<AND<T>>;
1461
- /**
1462
- * Computes a type-level NOR for a tuple of types.
1463
- *
1464
- * Truth table for 3 arguments:
1465
- *
1466
- * A B C = NOR
1467
- * 1 1 1 = 0
1468
- * 1 1 0 = 0
1469
- * 1 0 1 = 0
1470
- * 1 0 0 = 0
1471
- * 0 1 1 = 0
1472
- * 0 1 0 = 0
1473
- * 0 0 1 = 0
1474
- * 0 0 0 = 1
1475
- *
1476
- * @template T - Tuple of boolean-like types (1/0)
1477
- */
1478
- type NOR<T extends any[]> = NOT<OR<T>>;
1479
- //#endregion
1480
- //#region src/types/guards.d.ts
1481
- /**
1482
- * Represents primitive JavaScript types including null and undefined.
1483
- */
1484
- type Primitive = string | number | bigint | boolean | symbol | null | undefined;
1485
- /**
1486
- * Represents all falsy values in JavaScript.
1487
- */
1488
- type Falsy = false | '' | 0 | null | undefined;
1489
- /**
1490
- * Type guard that checks if a value is falsy.
1491
- *
1492
- * @param val - The value to check
1493
- * @returns True if the value is falsy, false otherwise
1494
- *
1495
- * @example
1496
- * if (isFalsy(value)) {
1497
- * console.log('Value is falsy');
1498
- * }
1499
- */
1500
- declare const isFalsy: (val: unknown) => val is Falsy;
1501
- /**
1502
- * Type guard that checks if a value is null or undefined.
1503
- *
1504
- * @param val - The value to check
1505
- * @returns True if the value is null or undefined, false otherwise
1506
- *
1507
- * @example
1508
- * if (isNullish(value)) {
1509
- * console.log('Value is null or undefined');
1510
- * }
1511
- */
1512
- declare const isNullish: (val: unknown) => val is null | undefined;
1513
- /**
1514
- * Type guard that checks if a value is a primitive type.
1515
- *
1516
- * @param val - The value to check
1517
- * @returns True if the value is a primitive, false otherwise
1518
- *
1519
- * @example
1520
- * if (isPrimitive(value)) {
1521
- * console.log('Value is a primitive type');
1522
- * }
1523
- */
1524
- declare const isPrimitive: (val: unknown) => val is Primitive;
1525
- /**
1526
- * Type guard that checks if a value is a plain object (not an array, function, etc.).
1527
- *
1528
- * @param value - The value to check
1529
- * @returns True if the value is a plain object, false otherwise
1530
- *
1531
- * @example
1532
- * if (isPlainObject(value)) {
1533
- * console.log('Value is a plain object');
1534
- * }
1535
- */
1536
- declare function isPlainObject(value: unknown): value is Record<string, any>;
1537
- //#endregion
1538
- 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 };