@wistia/utils 0.0.0-stage → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1560 @@
1
+
2
+ /*
3
+ * @license @wistia/utils v0.17.0
4
+ *
5
+ * Copyright (c) 2023-2026, Wistia, Inc. and its affiliates.
6
+ *
7
+ * This source code is unlicensed, all rights reserved.
8
+ */
9
+
10
+ import { EmptyObject, Get, Paths, UnknownRecord } from "type-fest";
11
+ //#region src/guards/hasKey.d.ts
12
+ /**
13
+ * Curried function that tests if an input is an object
14
+ * _and_ that a key that was passed in is a property of that object.
15
+ *
16
+ * @param value - The input object to test.
17
+ * @param key - The key to test if it is a property of the input record.
18
+ * @returns A function that takes an unknown input and then tests if the
19
+ * input is an object and whether the key is a property of that object or not.
20
+ *
21
+ * @example
22
+ * hasKey({ a: 1 }, 'a'); // true
23
+ * hasKey({ a: 1 }, 'b'); // false
24
+ *
25
+ * @category Records
26
+ */
27
+ export declare const hasKey: <Key extends string, Value>(value: unknown, key: Key) => value is Record<Key, Value>;
28
+ //#endregion
29
+ //#region src/guards/isArray.d.ts
30
+ /**
31
+ * Checks if the provided value is an array.
32
+ *
33
+ * @param value - The value to check.
34
+ * @returns True if the value is an array, false otherwise.
35
+ *
36
+ * @example
37
+ * isArray([1, 2]); // true
38
+ * isArray('abc'); // false
39
+ *
40
+ * @category Arrays
41
+ */
42
+ export declare const isArray: (value: unknown) => value is unknown[];
43
+ //#endregion
44
+ //#region src/guards/isAsyncFunction.d.ts
45
+ /**
46
+ * Checks if the provided value is an async function.
47
+ *
48
+ * @param value - The value to check.
49
+ * @returns True if the value is an async function, false otherwise.
50
+ *
51
+ * @remarks
52
+ * Detection relies on `constructor.name === 'AsyncFunction'` and is a
53
+ * heuristic: async functions transpiled to regular functions return false,
54
+ * async generator functions return false, and a forged `constructor`
55
+ * property can fool the check. Bound async functions return true, since
56
+ * `bind` preserves the prototype chain. Synchronous functions that return
57
+ * promises also return false.
58
+ *
59
+ * @example
60
+ * isAsyncFunction(async () => {}); // true
61
+ * isAsyncFunction(() => {}); // false
62
+ *
63
+ * @category Primitives
64
+ */
65
+ export declare const isAsyncFunction: (value: unknown) => value is (...args: unknown[]) => Promise<unknown>;
66
+ //#endregion
67
+ //#region src/guards/isBigInt.d.ts
68
+ /**
69
+ * Checks if the provided value is a bigint.
70
+ *
71
+ * @param value - The value to check.
72
+ * @returns True if the value is a bigint, false otherwise.
73
+ *
74
+ * @example
75
+ * isBigInt(10n); // true
76
+ * isBigInt(10); // false
77
+ *
78
+ * @category Primitives
79
+ */
80
+ export declare const isBigInt: (value: unknown) => value is bigint;
81
+ //#endregion
82
+ //#region src/guards/isBoolean.d.ts
83
+ /**
84
+ * Checks if the provided value is a boolean.
85
+ *
86
+ * @param value - The value to check.
87
+ * @returns True if the value is a boolean, false otherwise.
88
+ *
89
+ * @example
90
+ * isBoolean(true); // true
91
+ * isBoolean(1); // false
92
+ *
93
+ * @category Primitives
94
+ */
95
+ export declare const isBoolean: (value: unknown) => value is boolean;
96
+ //#endregion
97
+ //#region src/guards/isDate.d.ts
98
+ /**
99
+ * Checks if the provided value is an instance of Date.
100
+ *
101
+ * @param value - The value to check.
102
+ * @returns True if the value is a Date instance, false otherwise.
103
+ *
104
+ * @remarks
105
+ * Matches `Date` instances only. Does not parse date strings or
106
+ * accept numeric timestamps.
107
+ *
108
+ * @example
109
+ * isDate(new Date()); // true
110
+ * isDate('2024-01-01'); // false
111
+ *
112
+ * @category Primitives
113
+ */
114
+ export declare const isDate: (value: unknown) => value is Date;
115
+ //#endregion
116
+ //#region src/guards/isEmptyArray.d.ts
117
+ /**
118
+ * Checks if the provided value is an empty array.
119
+ *
120
+ * @param value - The value to check.
121
+ * @returns True if the value is an empty array, false otherwise.
122
+ *
123
+ * @example
124
+ * isEmptyArray([]); // true
125
+ * isEmptyArray([1]); // false
126
+ *
127
+ * @category Arrays
128
+ */
129
+ export declare const isEmptyArray: (value: unknown) => value is never[];
130
+ //#endregion
131
+ //#region src/guards/isEmptyRecord.d.ts
132
+ /**
133
+ * Checks if the provided value is an object with no own properties.
134
+ *
135
+ * @param value - The value to check.
136
+ * @returns True if the value is an empty object, false otherwise.
137
+ *
138
+ * @example
139
+ * isEmptyRecord({}); // true
140
+ * isEmptyRecord({ a: 1 }); // false
141
+ *
142
+ * @category Records
143
+ */
144
+ export declare const isEmptyRecord: (value: unknown) => value is EmptyObject;
145
+ //#endregion
146
+ //#region src/guards/isEmptyString.d.ts
147
+ /**
148
+ * Checks if the provided value is an empty string.
149
+ *
150
+ * @param value - The value to check.
151
+ * @returns True if the value is an empty string, false otherwise.
152
+ *
153
+ * @example
154
+ * isEmptyString(''); // true
155
+ * isEmptyString('a'); // false
156
+ *
157
+ * @category Strings
158
+ */
159
+ export declare const isEmptyString: (value: unknown) => value is '';
160
+ //#endregion
161
+ //#region src/guards/isError.d.ts
162
+ /**
163
+ * Checks if the provided value is an instance of Error.
164
+ *
165
+ * @param value - The value to check.
166
+ * @returns True if the value is an Error instance, false otherwise.
167
+ *
168
+ * @remarks
169
+ * Matches subclasses of `Error` too (e.g. `TypeError`, custom errors).
170
+ *
171
+ * @example
172
+ * isError(new Error('boom')); // true
173
+ * isError('boom'); // false
174
+ *
175
+ * @category Primitives
176
+ */
177
+ export declare const isError: (value: unknown) => value is Error;
178
+ //#endregion
179
+ //#region src/types/Falsy.d.ts
180
+ /**
181
+ * Represents a value that is falsy.
182
+ *
183
+ * @example
184
+ * type X = Falsy; // number | '' | 0n | false | null | undefined
185
+ */
186
+ type Falsy = typeof NaN | '' | 0n | false | null | undefined;
187
+ //#endregion
188
+ //#region src/guards/isFalsy.d.ts
189
+ /**
190
+ * Checks if the provided value is falsy.
191
+ *
192
+ * @param value - The value to check.
193
+ * @returns True if the value is falsy, false otherwise.
194
+ *
195
+ * @remarks
196
+ * Returns true for `false`, `0`, `-0`, `0n`, `''`, `null`, `undefined`,
197
+ * and `NaN`.
198
+ *
199
+ * @example
200
+ * isFalsy(0); // true
201
+ * isFalsy(1); // false
202
+ *
203
+ * @category Truthy / falsy
204
+ */
205
+ export declare const isFalsy: (value: unknown) => value is Falsy;
206
+ //#endregion
207
+ //#region src/guards/isFiniteNumber.d.ts
208
+ /**
209
+ * Checks if the provided value is a finite number.
210
+ *
211
+ * @param value - The value to check.
212
+ * @returns True if the value is a finite number, false otherwise.
213
+ *
214
+ * @example
215
+ * isFiniteNumber(42); // true
216
+ * isFiniteNumber(Infinity); // false
217
+ *
218
+ * @category Primitives
219
+ */
220
+ export declare const isFiniteNumber: (value: unknown) => value is number;
221
+ //#endregion
222
+ //#region src/guards/isFunction.d.ts
223
+ /**
224
+ * Checks if the provided value is a function.
225
+ *
226
+ * @param value - The value to check.
227
+ * @returns True if the value is a function, false otherwise.
228
+ *
229
+ * @example
230
+ * isFunction(() => {}); // true
231
+ * isFunction({}); // false
232
+ *
233
+ * @category Primitives
234
+ */
235
+ export declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
236
+ //#endregion
237
+ //#region src/guards/isHtmlButtonElement.d.ts
238
+ /**
239
+ * Checks if the provided value is an HTMLButtonElement.
240
+ *
241
+ * @param value - The value to check.
242
+ * @returns True if the value is an HTMLButtonElement, false otherwise.
243
+ *
244
+ * @example
245
+ * isHtmlButtonElement(document.createElement('button')); // true
246
+ * isHtmlButtonElement(document.createElement('div')); // false
247
+ *
248
+ * @category DOM
249
+ */
250
+ export declare const isHtmlButtonElement: (value: unknown) => value is HTMLButtonElement;
251
+ //#endregion
252
+ //#region src/guards/isHtmlElement.d.ts
253
+ /**
254
+ * Checks if the provided value is an HTMLElement.
255
+ *
256
+ * @param value - The value to check.
257
+ * @returns True if the value is an HTMLElement, false otherwise.
258
+ *
259
+ * @example
260
+ * isHtmlElement(document.body); // true
261
+ * isHtmlElement('div'); // false
262
+ *
263
+ * @category DOM
264
+ */
265
+ export declare const isHtmlElement: (value: unknown) => value is HTMLElement;
266
+ //#endregion
267
+ //#region src/guards/isHtmlInputElement.d.ts
268
+ /**
269
+ * Checks if the provided value is an HTMLInputElement.
270
+ *
271
+ * @param value - The value to check.
272
+ * @returns True if the value is an HTMLInputElement, false otherwise.
273
+ *
274
+ * @example
275
+ * isHtmlInputElement(document.createElement('input')); // true
276
+ * isHtmlInputElement(document.createElement('div')); // false
277
+ *
278
+ * @category DOM
279
+ */
280
+ export declare const isHtmlInputElement: (value: unknown) => value is HTMLInputElement;
281
+ //#endregion
282
+ //#region src/guards/isHtmlVideoElement.d.ts
283
+ /**
284
+ * Checks if the provided value is an HTMLVideoElement.
285
+ *
286
+ * @param value - The value to check.
287
+ * @returns True if the value is an HTMLVideoElement, false otherwise.
288
+ *
289
+ * @example
290
+ * isHtmlVideoElement(document.createElement('video')); // true
291
+ * isHtmlVideoElement(document.createElement('div')); // false
292
+ *
293
+ * @category DOM
294
+ */
295
+ export declare const isHtmlVideoElement: (value: unknown) => value is HTMLVideoElement;
296
+ //#endregion
297
+ //#region src/guards/isInteger.d.ts
298
+ /**
299
+ * Checks if the provided value is an integer.
300
+ *
301
+ * @param value - The value to check.
302
+ * @returns True if the value is an integer, false otherwise.
303
+ *
304
+ * @remarks
305
+ * Uses `Number.isInteger`, so non-finite values (`NaN`, `Infinity`)
306
+ * return false.
307
+ *
308
+ * @example
309
+ * isInteger(5); // true
310
+ * isInteger(5.5); // false
311
+ *
312
+ * @category Primitives
313
+ */
314
+ export declare const isInteger: (value: unknown) => value is number;
315
+ //#endregion
316
+ //#region src/guards/isIterable.d.ts
317
+ /**
318
+ * Checks if the provided value implements the iterable protocol.
319
+ *
320
+ * @param value - The value to check.
321
+ * @returns True if the value is iterable, false otherwise.
322
+ *
323
+ * @remarks
324
+ * Strings are iterable and return true. Plain objects without
325
+ * `Symbol.iterator` return false.
326
+ *
327
+ * @example
328
+ * isIterable([1, 2, 3]); // true
329
+ * isIterable({}); // false
330
+ *
331
+ * @category Primitives
332
+ */
333
+ export declare const isIterable: (value: unknown) => value is Iterable<unknown>;
334
+ //#endregion
335
+ //#region src/guards/isMap.d.ts
336
+ /**
337
+ * Checks if the provided value is an instance of Map.
338
+ *
339
+ * @param value - The value to check.
340
+ * @returns True if the value is a Map instance, false otherwise.
341
+ *
342
+ * @remarks
343
+ * WeakMap instances return false.
344
+ *
345
+ * @example
346
+ * isMap(new Map()); // true
347
+ * isMap({}); // false
348
+ *
349
+ * @category Primitives
350
+ */
351
+ export declare const isMap: (value: unknown) => value is Map<unknown, unknown>;
352
+ //#endregion
353
+ //#region src/guards/isMouseEvent.d.ts
354
+ /**
355
+ * Checks if the provided value is a MouseEvent.
356
+ *
357
+ * @param value - The value to check.
358
+ * @returns True if the value is a MouseEvent, false otherwise.
359
+ *
360
+ * @example
361
+ * isMouseEvent(new MouseEvent('click')); // true
362
+ * isMouseEvent(new Event('change')); // false
363
+ *
364
+ * @category DOM
365
+ */
366
+ export declare const isMouseEvent: (value: unknown) => value is MouseEvent;
367
+ //#endregion
368
+ //#region src/guards/isNaN.d.ts
369
+ /**
370
+ * Checks if the provided value is NaN (Not a Number).
371
+ *
372
+ * @param value - The value to check.
373
+ * @returns True if the value is NaN, false otherwise.
374
+ *
375
+ * @remarks
376
+ * Uses `Number.isNaN` (not the coercive global `isNaN`), so only the
377
+ * literal `NaN` value returns true.
378
+ *
379
+ * @example
380
+ * isNaN(Number.NaN); // true
381
+ * isNaN(0); // false
382
+ *
383
+ * @category Primitives
384
+ */
385
+ export declare const isNaN: (value: unknown) => value is number;
386
+ //#endregion
387
+ //#region src/types/Nil.d.ts
388
+ /**
389
+ * Represents a value that is either null or undefined.
390
+ *
391
+ * @example
392
+ * type X = Nil; // null | undefined
393
+ */
394
+ type Nil = null | undefined;
395
+ //#endregion
396
+ //#region src/guards/isNil.d.ts
397
+ /**
398
+ * Checks if the provided value is null or undefined.
399
+ *
400
+ * @param value - The value to check.
401
+ * @returns True if the value is null or undefined, false otherwise.
402
+ *
403
+ * @example
404
+ * isNil(null); // true
405
+ * isNil(0); // false
406
+ *
407
+ * @category Primitives
408
+ */
409
+ export declare const isNil: (value: unknown) => value is Nil;
410
+ //#endregion
411
+ //#region src/guards/isNonBlankString.d.ts
412
+ /**
413
+ * Checks if the provided value is a non-blank string (not empty and not whitespace-only).
414
+ * Use {@link isNonEmptyString} when whitespace-only strings are acceptable (e.g. preserving
415
+ * intentional formatting).
416
+ *
417
+ * @param value - The value to check.
418
+ * @returns True if the value is a string with at least one non-whitespace character, false otherwise.
419
+ *
420
+ * @example
421
+ * isNonBlankString('a'); // true
422
+ * isNonBlankString(' '); // false
423
+ *
424
+ * @category Strings
425
+ */
426
+ export declare const isNonBlankString: (value: unknown) => value is string;
427
+ //#endregion
428
+ //#region src/types/Nilable.d.ts
429
+ /**
430
+ * Represents a value that can be of type `A` or be null/undefined.
431
+ *
432
+ * @template A - The type of the value.
433
+ *
434
+ * @example
435
+ * type Maybe = Nilable<string>; // string | null | undefined
436
+ */
437
+ type Nilable<A> = A | Nil;
438
+ //#endregion
439
+ //#region src/types/NonEmptyArray.d.ts
440
+ /**
441
+ * Represents an array that contains at least one element.
442
+ *
443
+ * @template T - The type of the array elements.
444
+ *
445
+ * @example
446
+ * type Ids = NonEmptyArray<number>; // [number, ...number[]]
447
+ */
448
+ type NonEmptyArray<T> = [T, ...T[]];
449
+ //#endregion
450
+ //#region src/guards/isNonEmptyArray.d.ts
451
+ /**
452
+ * Checks if the provided value is a non-empty array.
453
+ *
454
+ * @param value - The value to check. Can be null or undefined.
455
+ * @returns True if the value is a non-empty array, false otherwise.
456
+ *
457
+ * @example
458
+ * isNonEmptyArray([1]); // true
459
+ * isNonEmptyArray([]); // false
460
+ *
461
+ * @category Arrays
462
+ */
463
+ export declare const isNonEmptyArray: <T>(value: Nilable<T[] | UnknownRecord>) => value is NonEmptyArray<T>;
464
+ //#endregion
465
+ //#region src/guards/isNonEmptyRecord.d.ts
466
+ /**
467
+ * Checks if the provided value is an object with at least one own property.
468
+ *
469
+ * @param value - The value to check.
470
+ * @returns True if the value is a non-empty object, false otherwise.
471
+ *
472
+ * @example
473
+ * isNonEmptyRecord({ a: 1 }); // true
474
+ * isNonEmptyRecord({}); // false
475
+ *
476
+ * @category Records
477
+ */
478
+ export declare const isNonEmptyRecord: (value: unknown) => value is Record<string, unknown>;
479
+ //#endregion
480
+ //#region src/guards/isNonEmptyString.d.ts
481
+ /**
482
+ * Checks if the provided value is a non-empty string. Whitespace-only strings like `" "` pass.
483
+ * Use {@link isNonBlankString} when whitespace-only strings should be rejected (e.g. user input
484
+ * validation).
485
+ *
486
+ * @param value - The value to check.
487
+ * @returns True if the value is a non-empty string, false otherwise.
488
+ *
489
+ * @example
490
+ * isNonEmptyString('a'); // true
491
+ * isNonEmptyString(''); // false
492
+ *
493
+ * @category Strings
494
+ */
495
+ export declare const isNonEmptyString: (value: unknown) => value is string;
496
+ //#endregion
497
+ //#region src/guards/isNonNaNNumber.d.ts
498
+ /**
499
+ * Checks if the provided value is a number that is not NaN.
500
+ *
501
+ * @param value - The value to check.
502
+ * @returns True if the value is a number and not NaN, false otherwise.
503
+ *
504
+ * @example
505
+ * isNonNaNNumber(42); // true
506
+ * isNonNaNNumber(Number.NaN); // false
507
+ *
508
+ * @category Primitives
509
+ */
510
+ export declare const isNonNaNNumber: (value: unknown) => value is number;
511
+ //#endregion
512
+ //#region src/guards/isNotArray.d.ts
513
+ /**
514
+ * Checks if the provided value is not an array.
515
+ *
516
+ * @param value - The value to check.
517
+ * @returns True if the value is not an array, false otherwise.
518
+ *
519
+ * @example
520
+ * isNotArray('x'); // true
521
+ * isNotArray([]); // false
522
+ *
523
+ * @category Negated
524
+ */
525
+ export declare const isNotArray: (value: unknown) => value is Exclude<unknown, unknown[]>;
526
+ //#endregion
527
+ //#region src/guards/isNotBoolean.d.ts
528
+ /**
529
+ * Checks if the provided value is not a boolean.
530
+ *
531
+ * @param value - The value to check.
532
+ * @returns True if the value is not a boolean, false otherwise.
533
+ *
534
+ * @example
535
+ * isNotBoolean(1); // true
536
+ * isNotBoolean(true); // false
537
+ *
538
+ * @category Negated
539
+ */
540
+ export declare const isNotBoolean: (value: unknown) => value is Exclude<unknown, boolean>;
541
+ //#endregion
542
+ //#region src/guards/isNotFunction.d.ts
543
+ /**
544
+ * Checks if the provided value is not a function.
545
+ *
546
+ * @param value - The value to check.
547
+ * @returns True if the value is not a function, false otherwise.
548
+ *
549
+ * @example
550
+ * isNotFunction(1); // true
551
+ * isNotFunction(() => {}); // false
552
+ *
553
+ * @category Negated
554
+ */
555
+ export declare const isNotFunction: (value: unknown) => value is Exclude<unknown, (...args: unknown[]) => unknown>;
556
+ //#endregion
557
+ //#region src/guards/isNotNil.d.ts
558
+ /**
559
+ * Checks if the provided value is neither null nor undefined.
560
+ *
561
+ * @param value - The value to check.
562
+ * @returns True if the value is not null or undefined, false otherwise.
563
+ *
564
+ * @remarks
565
+ * Common in `.filter(isNotNil)` to drop `null`/`undefined` from arrays
566
+ * with narrowing.
567
+ *
568
+ * @example
569
+ * isNotNil(0); // true
570
+ * isNotNil(null); // false
571
+ *
572
+ * const items: (string | null)[] = ['a', null, 'b'];
573
+ * const clean: string[] = items.filter(isNotNil); // ['a', 'b']
574
+ *
575
+ * @category Negated
576
+ */
577
+ export declare const isNotNil: <T>(value: Nil | T) => value is T;
578
+ //#endregion
579
+ //#region src/guards/isNotNull.d.ts
580
+ /**
581
+ * Checks if the provided value is not null.
582
+ *
583
+ * @param value - The value to check.
584
+ * @returns True if the value is not null, false otherwise.
585
+ *
586
+ * @example
587
+ * isNotNull(undefined); // true
588
+ * isNotNull(null); // false
589
+ *
590
+ * @category Negated
591
+ */
592
+ export declare const isNotNull: <T>(value: unknown) => value is Exclude<T, null>;
593
+ //#endregion
594
+ //#region src/guards/isNotNumber.d.ts
595
+ /**
596
+ * Checks if the provided value is not a number.
597
+ *
598
+ * @param value - The value to check.
599
+ * @returns True if the value is not a number, false otherwise.
600
+ *
601
+ * @example
602
+ * isNotNumber('1'); // true
603
+ * isNotNumber(1); // false
604
+ *
605
+ * @category Negated
606
+ */
607
+ export declare const isNotNumber: (value: unknown) => value is Exclude<unknown, number>;
608
+ //#endregion
609
+ //#region src/guards/isNotRecord.d.ts
610
+ /**
611
+ * Checks if the provided value is not an object.
612
+ *
613
+ * @param value - The value to check.
614
+ * @returns True if the value is not a record (object), false otherwise.
615
+ *
616
+ * @example
617
+ * isNotRecord([]); // true
618
+ * isNotRecord({}); // false
619
+ *
620
+ * @category Negated
621
+ */
622
+ export declare const isNotRecord: (value: unknown) => value is Exclude<unknown, Record<string, unknown>>;
623
+ //#endregion
624
+ //#region src/guards/isNotString.d.ts
625
+ /**
626
+ * Checks if the provided value is not a string.
627
+ *
628
+ * @param value - The value to check.
629
+ * @returns True if the value is not a string, false otherwise.
630
+ *
631
+ * @example
632
+ * isNotString(1); // true
633
+ * isNotString('a'); // false
634
+ *
635
+ * @category Negated
636
+ */
637
+ export declare const isNotString: (value: unknown) => value is Exclude<unknown, string>;
638
+ //#endregion
639
+ //#region src/types/Undefinable.d.ts
640
+ /**
641
+ * Represents a value that can be of type `A` or `undefined`.
642
+ *
643
+ * @template A - The type of the value.
644
+ *
645
+ * @example
646
+ * type X = Undefinable<string>; // string | undefined
647
+ */
648
+ type Undefinable<A> = A | undefined;
649
+ //#endregion
650
+ //#region src/guards/isNotUndefined.d.ts
651
+ /**
652
+ * Checks if the provided value is not undefined.
653
+ *
654
+ * @param value - The value to check.
655
+ * @returns True if the value is not undefined, false otherwise.
656
+ *
657
+ * @example
658
+ * isNotUndefined(null); // true
659
+ * isNotUndefined(undefined); // false
660
+ *
661
+ * @category Negated
662
+ */
663
+ export declare const isNotUndefined: <T>(value: Undefinable<T>) => value is Exclude<T, undefined>;
664
+ //#endregion
665
+ //#region src/guards/isNotVoid.d.ts
666
+ /**
667
+ * Checks if the provided value is not void.
668
+ *
669
+ * @param value - The value to check.
670
+ * @returns True if the value is not void (defined), false otherwise.
671
+ *
672
+ * @example
673
+ * isNotVoid(0); // true
674
+ * isNotVoid(undefined); // false
675
+ *
676
+ * @category Negated
677
+ */
678
+ export declare const isNotVoid: (value: unknown) => value is Exclude<unknown, void>;
679
+ //#endregion
680
+ //#region src/guards/isNull.d.ts
681
+ /**
682
+ * Checks if the provided value is null.
683
+ *
684
+ * @param value - The value to check.
685
+ * @returns True if the value is null, false otherwise.
686
+ *
687
+ * @example
688
+ * isNull(null); // true
689
+ * isNull(undefined); // false
690
+ *
691
+ * @category Primitives
692
+ */
693
+ export declare const isNull: (value: unknown) => value is null;
694
+ //#endregion
695
+ //#region src/guards/isNumber.d.ts
696
+ /**
697
+ * Checks if the provided value is a number.
698
+ *
699
+ * @param value - The value to check.
700
+ * @returns True if the value is a number, false otherwise.
701
+ *
702
+ * @remarks
703
+ * `NaN` is a `number`, so `isNumber(NaN)` is true. Use `isInteger` or
704
+ * combine with `!isNaN(value)` if you need a finite number.
705
+ *
706
+ * @example
707
+ * isNumber(1); // true
708
+ * isNumber('1'); // false
709
+ *
710
+ * @category Primitives
711
+ */
712
+ export declare const isNumber: (value: unknown) => value is number;
713
+ //#endregion
714
+ //#region src/guards/isPlainObject.d.ts
715
+ /**
716
+ * Checks if the provided value is a plain object created with `{}` or `Object.create(null)`.
717
+ * Returns false for arrays, `Date`, `Map`, `RegExp`, boxed primitives, and class instances.
718
+ *
719
+ * @param value - The value to check.
720
+ * @returns True if the value is a plain object, false otherwise.
721
+ *
722
+ * @example
723
+ * isPlainObject({}); // true
724
+ * isPlainObject(new Date()); // false
725
+ *
726
+ * @category Records
727
+ */
728
+ export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
729
+ //#endregion
730
+ //#region src/guards/isPromise.d.ts
731
+ /**
732
+ * Checks if the provided value is a Promise, including promise-like objects
733
+ * that implement `then`, `catch`, and `finally`.
734
+ *
735
+ * @param value - The value to check.
736
+ * @returns True if the value is a Promise or promise-like object, false otherwise.
737
+ *
738
+ * @remarks
739
+ * The full `Promise` method surface is required so the narrowed type is
740
+ * accurate: `then`, `catch`, and `finally` must all be functions. Thenables
741
+ * that only implement a subset are rejected.
742
+ *
743
+ * @example
744
+ * isPromise(Promise.resolve()); // true
745
+ * isPromise({ then: () => 1 }); // false
746
+ *
747
+ * @category Primitives
748
+ */
749
+ export declare const isPromise: (value: unknown) => value is Promise<unknown>;
750
+ //#endregion
751
+ //#region src/guards/isRecord.d.ts
752
+ /**
753
+ * Checks if the provided value is a non-null object that is not an array.
754
+ *
755
+ * @param value - The value to check.
756
+ * @returns True if the value is an object (but not an array), false otherwise.
757
+ *
758
+ * @example
759
+ * isRecord({}); // true
760
+ * isRecord([]); // false
761
+ *
762
+ * @category Records
763
+ */
764
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
765
+ //#endregion
766
+ //#region src/guards/isRegExp.d.ts
767
+ /**
768
+ * Checks if the provided value is an instance of RegExp.
769
+ *
770
+ * @param value - The value to check.
771
+ * @returns True if the value is a RegExp instance, false otherwise.
772
+ *
773
+ * @example
774
+ * isRegExp(/abc/); // true
775
+ * isRegExp('/abc/'); // false
776
+ *
777
+ * @category Primitives
778
+ */
779
+ export declare const isRegExp: (value: unknown) => value is RegExp;
780
+ //#endregion
781
+ //#region src/guards/isSet.d.ts
782
+ /**
783
+ * Checks if the provided value is an instance of Set.
784
+ *
785
+ * @param value - The value to check.
786
+ * @returns True if the value is a Set instance, false otherwise.
787
+ *
788
+ * @remarks
789
+ * WeakSet instances return false.
790
+ *
791
+ * @example
792
+ * isSet(new Set()); // true
793
+ * isSet([]); // false
794
+ *
795
+ * @category Primitives
796
+ */
797
+ export declare const isSet: (value: unknown) => value is Set<unknown>;
798
+ //#endregion
799
+ //#region src/guards/isString.d.ts
800
+ /**
801
+ * Checks if the provided value is a string.
802
+ *
803
+ * @param value - The value to check.
804
+ * @returns True if the value is a string, false otherwise.
805
+ *
806
+ * @example
807
+ * isString('hi'); // true
808
+ * isString(42); // false
809
+ *
810
+ * @category Primitives
811
+ */
812
+ export declare const isString: (value: unknown) => value is string;
813
+ //#endregion
814
+ //#region src/guards/isSvgElement.d.ts
815
+ /**
816
+ * Checks if the provided value is an SVGElement.
817
+ *
818
+ * @param value - The value to check.
819
+ * @returns True if the value is an SVGElement, false otherwise.
820
+ *
821
+ * @example
822
+ * isSvgElement(document.createElementNS('http://www.w3.org/2000/svg', 'svg')); // true
823
+ * isSvgElement(document.createElement('div')); // false
824
+ *
825
+ * @category DOM
826
+ */
827
+ export declare const isSvgElement: (value: unknown) => value is SVGElement;
828
+ //#endregion
829
+ //#region src/guards/isSymbol.d.ts
830
+ /**
831
+ * Checks if the provided value is a symbol.
832
+ *
833
+ * @param value - The value to check.
834
+ * @returns True if the value is a symbol, false otherwise.
835
+ *
836
+ * @example
837
+ * isSymbol(Symbol('a')); // true
838
+ * isSymbol('symbol'); // false
839
+ *
840
+ * @category Primitives
841
+ */
842
+ export declare const isSymbol: (value: unknown) => value is symbol;
843
+ //#endregion
844
+ //#region src/guards/isTextNode.d.ts
845
+ /**
846
+ * Checks if the provided value is a Text node.
847
+ *
848
+ * @param value - The value to check.
849
+ * @returns True if the value is a Text node, false otherwise.
850
+ *
851
+ * @example
852
+ * isTextNode(document.createTextNode('hi')); // true
853
+ * isTextNode(document.createElement('div')); // false
854
+ *
855
+ * @category DOM
856
+ */
857
+ export declare const isTextNode: (value: unknown) => value is Text;
858
+ //#endregion
859
+ //#region src/guards/isTruthy.d.ts
860
+ /**
861
+ * Checks if the provided value is truthy.
862
+ *
863
+ * @param value - The value to check.
864
+ * @returns True if the value is truthy, false otherwise.
865
+ *
866
+ * @remarks
867
+ * The complement of `isFalsy`. Does not provide narrowing on its own;
868
+ * use `isNotNil` or a specific positive guard when narrowing matters.
869
+ *
870
+ * @example
871
+ * isTruthy(1); // true
872
+ * isTruthy(0); // false
873
+ *
874
+ * @category Truthy / falsy
875
+ */
876
+ export declare const isTruthy: (value: unknown) => boolean;
877
+ //#endregion
878
+ //#region src/guards/isUndefined.d.ts
879
+ /**
880
+ * Checks if the provided value is undefined.
881
+ *
882
+ * @param value - The value to check.
883
+ * @returns True if the value is undefined, false otherwise.
884
+ *
885
+ * @example
886
+ * isUndefined(undefined); // true
887
+ * isUndefined(null); // false
888
+ *
889
+ * @category Primitives
890
+ */
891
+ export declare const isUndefined: (value: unknown) => value is undefined;
892
+ //#endregion
893
+ //#region src/guards/isVoid.d.ts
894
+ /**
895
+ * Checks if the provided value is void.
896
+ *
897
+ * @param value - The value to check.
898
+ * @returns True if the value is void (undefined), false otherwise.
899
+ *
900
+ * @example
901
+ * isVoid(undefined); // true
902
+ * isVoid(0); // false
903
+ *
904
+ * @category Primitives
905
+ */
906
+ export declare const isVoid: (value: unknown) => value is void;
907
+ //#endregion
908
+ //#region src/guards/isWeakMap.d.ts
909
+ /**
910
+ * Checks if the provided value is an instance of WeakMap.
911
+ *
912
+ * @param value - The value to check.
913
+ * @returns True if the value is a WeakMap instance, false otherwise.
914
+ *
915
+ * @remarks
916
+ * Map instances return false. Narrows to `WeakMap<WeakKey, unknown>`, since
917
+ * weak collections accept non-registered symbols as keys (ES2023).
918
+ *
919
+ * @example
920
+ * isWeakMap(new WeakMap()); // true
921
+ * isWeakMap(new Map()); // false
922
+ *
923
+ * @category Primitives
924
+ */
925
+ export declare const isWeakMap: (value: unknown) => value is WeakMap<WeakKey, unknown>;
926
+ //#endregion
927
+ //#region src/guards/isWeakSet.d.ts
928
+ /**
929
+ * Checks if the provided value is an instance of WeakSet.
930
+ *
931
+ * @param value - The value to check.
932
+ * @returns True if the value is a WeakSet instance, false otherwise.
933
+ *
934
+ * @remarks
935
+ * Set instances return false. Narrows to `WeakSet<WeakKey>`, since weak
936
+ * collections accept non-registered symbols as members (ES2023).
937
+ *
938
+ * @example
939
+ * isWeakSet(new WeakSet()); // true
940
+ * isWeakSet(new Set()); // false
941
+ *
942
+ * @category Primitives
943
+ */
944
+ export declare const isWeakSet: (value: unknown) => value is WeakSet<WeakKey>;
945
+ //#endregion
946
+ //#region src/guards/readonlyArrayIncludes.d.ts
947
+ /**
948
+ * Checks if a readonly array includes the given element, with type narrowing.
949
+ *
950
+ * @param arr - The readonly array to search.
951
+ * @param elem - The element to search for.
952
+ * @returns True if the array includes the element, false otherwise.
953
+ *
954
+ * @example
955
+ * const arr = ['a', 'b'] as const;
956
+ * readonlyArrayIncludes(arr, 'a'); // true
957
+ * readonlyArrayIncludes(arr, 'z'); // false
958
+ *
959
+ * @category Arrays
960
+ */
961
+ export declare const readonlyArrayIncludes: <T>(arr: readonly T[], elem: unknown) => elem is T;
962
+ //#endregion
963
+ //#region src/types/Arrayable.d.ts
964
+ /**
965
+ * Represents a value that can be of type `T` or an array of `T`.
966
+ *
967
+ * @template T - The type of the value.
968
+ *
969
+ * @example
970
+ * type Tags = Arrayable<string>; // string | string[]
971
+ */
972
+ type Arrayable<T> = T | T[];
973
+ //#endregion
974
+ //#region src/types/NestedNonNullable.d.ts
975
+ /**
976
+ * Retrieves the type of a deeply nested property from an object while removing null and undefined.
977
+ *
978
+ * @template T - The object type.
979
+ * @template P - The path to the nested property as a string literal.
980
+ *
981
+ * @remarks
982
+ * This type recursively traverses the object along the given path and applies `NonNullable` to the resulting type.
983
+ * It may fail for excessively deep property paths or in the presence of circular references. In such cases, consider
984
+ * using nested `NonNullable` definitions to avoid errors such as:
985
+ * - TS2589: Type instantiation is excessively deep and possibly infinite.
986
+ * - TS2615: Type of property 'XYZ' circularly references itself in mapped type.
987
+ *
988
+ * @example
989
+ * type User = { profile?: { name?: string } };
990
+ * type Name = NestedNonNullable<User, 'profile.name'>; // string
991
+ */
992
+ type NestedNonNullable<T, P extends Paths<T> & string> = NonNullable<Get<T, P>>;
993
+ //#endregion
994
+ //#region src/types/NilableArray.d.ts
995
+ /**
996
+ * Represents an array that can be null or undefined, and its elements can also be null or undefined.
997
+ *
998
+ * @template T - The type of the non-null/undefined elements in the array.
999
+ *
1000
+ * @example
1001
+ * type Items = NilableArray<string>; // (string | null | undefined)[] | null | undefined
1002
+ */
1003
+ type NilableArray<T> = Nilable<Nilable<T>[]>;
1004
+ //#endregion
1005
+ //#region src/types/NotNilable.d.ts
1006
+ /**
1007
+ * Represents a value of type `A` that is guaranteed to be neither null nor undefined.
1008
+ *
1009
+ * @template A - The type to be filtered.
1010
+ *
1011
+ * @example
1012
+ * type X = NotNilable<string | null | undefined>; // string
1013
+ */
1014
+ type NotNilable<A> = Exclude<A, Nil>;
1015
+ //#endregion
1016
+ //#region src/types/Nullable.d.ts
1017
+ /**
1018
+ * Represents a value that can be of type `A` or `null`.
1019
+ *
1020
+ * @template A - The type of the value.
1021
+ *
1022
+ * @example
1023
+ * type X = Nullable<string>; // string | null
1024
+ */
1025
+ type Nullable<A> = A | null;
1026
+ //#endregion
1027
+ //#region src/types/NullableProperties.d.ts
1028
+ /**
1029
+ * Makes every property of a record nullable.
1030
+ *
1031
+ * @template T - The record type.
1032
+ *
1033
+ * @example
1034
+ * type User = { name: string; age: number };
1035
+ * type X = NullableProperties<User>; // { name: string | null; age: number | null }
1036
+ */
1037
+ type NullableProperties<T extends UnknownRecord> = { [Key in keyof T]: Nullable<T[Key]>; };
1038
+ //#endregion
1039
+ //#region src/types/Truthy.d.ts
1040
+ /**
1041
+ * Represents a value that is truthy.
1042
+ *
1043
+ * @template T - The type of the value.
1044
+ *
1045
+ * @example
1046
+ * type X = Truthy<string | 0 | null>; // string
1047
+ */
1048
+ type Truthy<T> = Exclude<T, Falsy>;
1049
+ //#endregion
1050
+ //#region src/utilities/noOpFn.d.ts
1051
+ type NoOpFn = typeof noOpFn;
1052
+ /**
1053
+ * A function that does nothing. Useful as a default or placeholder callback.
1054
+ *
1055
+ * @returns Nothing.
1056
+ *
1057
+ * @example
1058
+ * noOpFn(); // undefined
1059
+ */
1060
+ export declare const noOpFn: () => void;
1061
+ //#endregion
1062
+ //#region src/utilities/asyncNoOpFn.d.ts
1063
+ type AsyncNoOpFn = typeof asyncNoOpFn;
1064
+ type AsyncOrSyncNoOpFn = AsyncNoOpFn | NoOpFn;
1065
+ /**
1066
+ * An async function that does nothing. Useful as a default or placeholder
1067
+ * callback where a promise is expected.
1068
+ *
1069
+ * @returns A promise that resolves to `undefined`.
1070
+ *
1071
+ * @example
1072
+ * await asyncNoOpFn(); // undefined
1073
+ */
1074
+ export declare const asyncNoOpFn: () => Promise<void>;
1075
+ //#endregion
1076
+ //#region src/utilities/buildTimeDuration.d.ts
1077
+ type TimeDuration = {
1078
+ seconds: number;
1079
+ minutes: number;
1080
+ hours: number;
1081
+ };
1082
+ /**
1083
+ * Returns an object representing a duration in seconds, minutes and hours.
1084
+ *
1085
+ * @param numberOfMilliseconds - The duration in milliseconds.
1086
+ * @returns The duration split into hours, minutes and seconds.
1087
+ *
1088
+ * @example
1089
+ * buildTimeDuration(3723000); // { hours: 1, minutes: 2, seconds: 3 }
1090
+ */
1091
+ export declare const buildTimeDuration: (numberOfMilliseconds: number) => TimeDuration;
1092
+ //#endregion
1093
+ //#region src/utilities/coerceToBoolean.d.ts
1094
+ /**
1095
+ * Converts the boolean string values 'true' and 'false' into the
1096
+ * corresponding boolean. Any other value is coerced with `Boolean()`.
1097
+ *
1098
+ * @param value - The value to coerce.
1099
+ * @returns The value as a boolean.
1100
+ *
1101
+ * @example
1102
+ * coerceToBoolean('true'); // true
1103
+ * coerceToBoolean('false'); // false
1104
+ * coerceToBoolean(0); // false
1105
+ */
1106
+ export declare const coerceToBoolean: (value: unknown) => boolean;
1107
+ //#endregion
1108
+ //#region src/utilities/dateOnlyString.d.ts
1109
+ type DateOnlyStringOptions = {
1110
+ timeZone?: string;
1111
+ /**
1112
+ * When set to true, the returned string will omit the year.
1113
+ * e.g. "Jun 3" instead of "Jun 3, 2021"
1114
+ */
1115
+ omitYear?: boolean;
1116
+ };
1117
+ /**
1118
+ * Converts a Date object into a date only string, e.g. 'Jun 3, 2021',
1119
+ * or 'Jun 3' if omitYear is true. Formats with the en-US locale.
1120
+ *
1121
+ * @param date - The Date to format; gracefully handles any value.
1122
+ * @param options - Formatting options.
1123
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1124
+ * @param options.omitYear - If true, display the date without the year.
1125
+ * @returns The formatted date string, or '' for invalid input.
1126
+ *
1127
+ * @example
1128
+ * dateOnlyString(new Date(2011, 11, 15)); // 'Dec 15, 2011'
1129
+ */
1130
+ export declare const dateOnlyString: (date: unknown, { timeZone, omitYear }?: DateOnlyStringOptions) => string;
1131
+ //#endregion
1132
+ //#region src/utilities/dateOnlyISOString.d.ts
1133
+ /**
1134
+ * Converts a Date object into a date only string formatted to ISO 8601,
1135
+ * e.g. '2021-06-03'.
1136
+ *
1137
+ * @param date - The Date to format; gracefully handles any value.
1138
+ * @param options - Formatting options.
1139
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1140
+ * @returns The formatted date string, or '' for invalid input.
1141
+ *
1142
+ * @example
1143
+ * dateOnlyISOString(new Date(2011, 11, 15)); // '2011-12-15'
1144
+ */
1145
+ export declare const dateOnlyISOString: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
1146
+ //#endregion
1147
+ //#region src/utilities/dateOnlyStringForSentence.d.ts
1148
+ /**
1149
+ * Converts a Date object into a date only string for use in a sentence,
1150
+ * e.g. 'June 3, 2021'. Formats with the en-US locale.
1151
+ *
1152
+ * @param date - The Date to format; gracefully handles any value.
1153
+ * @param options - Formatting options.
1154
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1155
+ * @returns The formatted date string, or '' for invalid input.
1156
+ *
1157
+ * @example
1158
+ * dateOnlyStringForSentence(new Date(2011, 11, 15)); // 'December 15, 2011'
1159
+ */
1160
+ export declare const dateOnlyStringForSentence: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
1161
+ //#endregion
1162
+ //#region src/utilities/dateOnlyStringNumeric.d.ts
1163
+ /**
1164
+ * Converts a Date object into a date only string formatted numerically,
1165
+ * e.g. '06/03/2021'. Formats with the en-US locale.
1166
+ *
1167
+ * @param date - The Date to format; gracefully handles any value.
1168
+ * @param options - Formatting options.
1169
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1170
+ * @returns The formatted date string, or '' for invalid input.
1171
+ *
1172
+ * @example
1173
+ * dateOnlyStringNumeric(new Date(2011, 11, 15)); // '12/15/2011'
1174
+ */
1175
+ export declare const dateOnlyStringNumeric: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
1176
+ //#endregion
1177
+ //#region src/utilities/dateTimeRounded.d.ts
1178
+ type DateTimeRoundedOverload = {
1179
+ (dateTime: Date, toISOString?: true): string | null;
1180
+ (dateTime: Date, toISOString: false): Date | null;
1181
+ };
1182
+ /**
1183
+ * Rounds a Date up to the next half hour boundary.
1184
+ *
1185
+ * @param dateTime - The Date to round.
1186
+ * @param toISOString - Whether to return an ISO-8601 string instead of a Date.
1187
+ * @returns The rounded value as a string or Date depending on toISOString.
1188
+ *
1189
+ * @example
1190
+ * dateTimeRounded(new Date(2015, 10, 7, 0, 10)); // '2015-11-07T00:30:00.000Z' (in UTC)
1191
+ * dateTimeRounded(new Date(2015, 10, 7, 0, 40), false); // new Date(2015, 10, 7, 1, 0)
1192
+ */
1193
+ export declare const dateTimeRounded: DateTimeRoundedOverload;
1194
+ //#endregion
1195
+ //#region src/utilities/dateTimeString.d.ts
1196
+ /**
1197
+ * Converts a Date, timestamp, or date string into a date and time string,
1198
+ * e.g. 'Jun 3, 2021, 11:52 AM'. Formats with the en-US locale.
1199
+ *
1200
+ * NOTE: you should probably use timeAgoString when trying to display
1201
+ * an updated/created timestamp.
1202
+ *
1203
+ * @param date - The Date, timestamp, or date string to format; gracefully handles any value.
1204
+ * @param options - Formatting options.
1205
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1206
+ * @param options.omitYear - If true, display the date without the year.
1207
+ * @returns The formatted date string, or '' for invalid input.
1208
+ *
1209
+ * @example
1210
+ * dateTimeString(new Date(2011, 11, 15, 7, 30)); // 'Dec 15, 2011, 7:30 AM'
1211
+ */
1212
+ export declare const dateTimeString: (date: Date | number | string | null | undefined, { timeZone, omitYear }?: DateOnlyStringOptions) => string;
1213
+ //#endregion
1214
+ //#region src/utilities/dateTimeStringForSentence.d.ts
1215
+ /**
1216
+ * Converts a Date object into a date and time string for use in a sentence,
1217
+ * e.g. 'June 3, 2021, 11:52 AM'. Formats with the en-US locale.
1218
+ *
1219
+ * NOTE: you should probably use timeAgoString when trying to display
1220
+ * an updated/created timestamp.
1221
+ *
1222
+ * @param date - The Date to format; gracefully handles any value.
1223
+ * @param options - Formatting options.
1224
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1225
+ * @returns The formatted date string, or '' for invalid input.
1226
+ *
1227
+ * @example
1228
+ * dateTimeStringForSentence(new Date(2011, 11, 15, 7, 30)); // 'December 15, 2011, 7:30 AM'
1229
+ */
1230
+ export declare const dateTimeStringForSentence: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
1231
+ //#endregion
1232
+ //#region src/utilities/dateToDateTime.d.ts
1233
+ type WistiaDateTimeObject = {
1234
+ minutes: number;
1235
+ hours: number;
1236
+ dayOfMonth: number;
1237
+ year: number;
1238
+ month: number;
1239
+ };
1240
+ /**
1241
+ * Converts a Date object into a plain object of its local date and time parts.
1242
+ *
1243
+ * @param date - The Date object to convert.
1244
+ * @returns The date parts, or null if the value is not a Date.
1245
+ *
1246
+ * @example
1247
+ * dateToDateTime(new Date(2011, 11, 15, 3, 10));
1248
+ * // { year: 2011, month: 11, dayOfMonth: 15, hours: 3, minutes: 10 }
1249
+ */
1250
+ export declare const dateToDateTime: (date: Date | null | undefined) => WistiaDateTimeObject | null;
1251
+ //#endregion
1252
+ //#region src/utilities/dateTimeToDate.d.ts
1253
+ /**
1254
+ * Converts a plain object of date and time parts into a Date object.
1255
+ *
1256
+ * @param dateTime - The date parts to convert.
1257
+ * @returns The converted Date, or null if year, month, or dayOfMonth is missing.
1258
+ *
1259
+ * @example
1260
+ * dateTimeToDate({ year: 2015, month: 10, dayOfMonth: 7, hours: 4, minutes: 15 });
1261
+ * // new Date(2015, 10, 7, 4, 15)
1262
+ */
1263
+ export declare const dateTimeToDate: (dateTime: Partial<WistiaDateTimeObject> | null | undefined) => Date | null;
1264
+ //#endregion
1265
+ //#region src/utilities/dateTimeToISO.d.ts
1266
+ /**
1267
+ * Converts a plain object of date and time parts into an ISO-8601 string.
1268
+ *
1269
+ * @param dateTime - The date parts to convert.
1270
+ * @returns The ISO-8601 string, or null if year, month, or dayOfMonth is missing.
1271
+ *
1272
+ * @example
1273
+ * dateTimeToISO({ year: 2015, month: 10, dayOfMonth: 7, hours: 4, minutes: 15 });
1274
+ * // '2015-11-07T04:15:00.000Z' (in UTC)
1275
+ */
1276
+ export declare const dateTimeToISO: (dateTime: Partial<WistiaDateTimeObject>) => string | null;
1277
+ //#endregion
1278
+ //#region src/utilities/dateUTCOffset.d.ts
1279
+ /**
1280
+ * Given a date, shows the UTC offset of the current time zone, e.g. '+02:00'.
1281
+ *
1282
+ * @param date - The Date to calculate the offset for.
1283
+ * @returns The UTC offset string.
1284
+ *
1285
+ * @example
1286
+ * dateUTCOffset(new Date(2011, 11, 15)); // '+00:00' (when run in UTC)
1287
+ */
1288
+ export declare const dateUTCOffset: (date: Date) => string;
1289
+ //#endregion
1290
+ //#region src/utilities/dayOfWeekString.d.ts
1291
+ /**
1292
+ * Converts a Date object into a day of the week string, e.g. 'Thursday'.
1293
+ * Formats with the en-US locale.
1294
+ *
1295
+ * @param date - The Date to format.
1296
+ * @param options - Formatting options.
1297
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1298
+ * @returns The formatted day of the week, or '' for null or invalid input.
1299
+ *
1300
+ * @example
1301
+ * dayOfWeekString(new Date(2011, 11, 15)); // 'Thursday'
1302
+ */
1303
+ export declare const dayOfWeekString: (date: Date | null, { timeZone }?: DateOnlyStringOptions) => string;
1304
+ //#endregion
1305
+ //#region src/utilities/deepMerge.d.ts
1306
+ type AllKeys<T> = T extends unknown ? Extract<keyof T, string | number> : never;
1307
+ type IndexValue<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? T[K] : never : never;
1308
+ type MergeableFunction = (...args: never[]) => unknown;
1309
+ type OverwrittenValues = string | number | boolean | bigint | symbol | Date | RegExp | Map<unknown, unknown> | Set<unknown> | Error | Promise<unknown> | MergeableFunction;
1310
+ type DeepMerged<T> = [T] extends [unknown[]] ? { [K in keyof T]: DeepMerged<T[K]>; } : [T] extends [OverwrittenValues] ? T : [T] extends [object] ? { [K in AllKeys<T>]: DeepMerged<IndexValue<T, K>>; } : T;
1311
+ type DeepMergeResult<T extends Record<string, unknown>[]> = [T[number]] extends [never] ? Record<string, never> : DeepMerged<T[number]>;
1312
+ /**
1313
+ * Deeply merges objects without mutating them, inferring the return type from
1314
+ * the inputs. Plain objects are merged recursively, arrays are concatenated
1315
+ * with duplicate items removed (by reference for object items), and all other
1316
+ * values (including class instances) are overwritten in the order of the
1317
+ * provided arguments. The prototype-polluting keys `__proto__`, `constructor`,
1318
+ * and `prototype` are dropped. Symbol-keyed properties are not merged.
1319
+ *
1320
+ * @param objects - The objects to merge.
1321
+ * @returns A new object containing the merged result.
1322
+ * @throws TypeError when an argument is an array.
1323
+ *
1324
+ * @example
1325
+ * deepMerge({ a: { b: 1 }, c: [1] }, { a: { d: 2 }, c: [2] });
1326
+ * // { a: { b: 1, d: 2 }, c: [1, 2] }
1327
+ */
1328
+ export declare const deepMerge: <T extends Record<string, unknown>[]>(...objects: T) => DeepMergeResult<T>;
1329
+ //#endregion
1330
+ //#region src/utilities/getObjectEntries.d.ts
1331
+ /**
1332
+ * Returns the entries of an object with strongly typed keys and values.
1333
+ *
1334
+ * @param obj - The object to get entries from.
1335
+ * @returns An array of [key, value] tuples.
1336
+ *
1337
+ * @example
1338
+ * getObjectEntries({ a: 1, b: 2 }); // [['a', 1], ['b', 2]]
1339
+ */
1340
+ export declare const getObjectEntries: <T extends Record<string, unknown>>(obj: T) => [keyof T, T[keyof T]][];
1341
+ //#endregion
1342
+ //#region src/utilities/getObjectKeys.d.ts
1343
+ /**
1344
+ * Returns the keys of an object with strongly typed key type.
1345
+ *
1346
+ * @param obj - The object to get keys from.
1347
+ * @returns An array of the object's keys.
1348
+ *
1349
+ * @example
1350
+ * getObjectKeys({ a: 1, b: 2 }); // ['a', 'b']
1351
+ */
1352
+ export declare const getObjectKeys: <T extends Record<string, unknown>>(obj: T) => (keyof T)[];
1353
+ //#endregion
1354
+ //#region src/utilities/getObjectValues.d.ts
1355
+ /**
1356
+ * Returns the values of an object with strongly typed value type.
1357
+ *
1358
+ * @param obj - The object to get values from.
1359
+ * @returns An array of the object's values.
1360
+ *
1361
+ * @example
1362
+ * getObjectValues({ a: 1, b: 2 }); // [1, 2]
1363
+ */
1364
+ export declare const getObjectValues: <T extends Record<string, unknown>>(obj: T) => T[keyof T][];
1365
+ //#endregion
1366
+ //#region src/utilities/isEmail.d.ts
1367
+ /**
1368
+ * Loosely validates an email address string.
1369
+ *
1370
+ * @param value - The string to validate.
1371
+ * @returns True if the string appears to be an email address, false otherwise.
1372
+ *
1373
+ * @example
1374
+ * isEmail('user@example.com'); // true
1375
+ * isEmail('user@example'); // false
1376
+ */
1377
+ export declare const isEmail: (value: string) => boolean;
1378
+ //#endregion
1379
+ //#region src/utilities/isUrl.d.ts
1380
+ /**
1381
+ * Loosely validates a URL string.
1382
+ *
1383
+ * @param value - The value to validate.
1384
+ * @returns True if the value appears to be a URL, false otherwise.
1385
+ *
1386
+ * @example
1387
+ * isUrl('https://wistia.com'); // true
1388
+ * isUrl('not a url'); // false
1389
+ */
1390
+ export declare const isUrl: (value: unknown) => boolean;
1391
+ //#endregion
1392
+ //#region src/utilities/mediaDurationString.d.ts
1393
+ /**
1394
+ * A string representation of a duration for a media. Assumes most medias
1395
+ * are under an hour so only shows hours if media is over an hour.
1396
+ *
1397
+ * @param numberOfMilliseconds - The duration in milliseconds.
1398
+ * @returns The formatted duration string.
1399
+ *
1400
+ * @example
1401
+ * mediaDurationString(234230); // '3:54'
1402
+ * mediaDurationString(23423000); // '6:30:23'
1403
+ */
1404
+ export declare const mediaDurationString: (numberOfMilliseconds: number) => string;
1405
+ //#endregion
1406
+ //#region src/utilities/millisecondsToDurationISOString.d.ts
1407
+ /**
1408
+ * Given a number of milliseconds, returns the ISO 8601 duration string
1409
+ * rounded down from the number of seconds.
1410
+ *
1411
+ * @param numberOfMilliseconds - The duration in milliseconds.
1412
+ * @returns The ISO 8601 duration string.
1413
+ *
1414
+ * @example
1415
+ * millisecondsToDurationISOString(33000); // 'PT33S'
1416
+ * millisecondsToDurationISOString(3605000); // 'PT1H5S'
1417
+ */
1418
+ export declare const millisecondsToDurationISOString: (numberOfMilliseconds: number) => string;
1419
+ //#endregion
1420
+ //#region src/utilities/monthDayStringNumeric.d.ts
1421
+ /**
1422
+ * Converts a Date object into a month and day string formatted numerically,
1423
+ * e.g. '06/03'. Formats with the en-US locale.
1424
+ *
1425
+ * @param date - The Date to format; gracefully handles any value.
1426
+ * @param options - Formatting options.
1427
+ * @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
1428
+ * @returns The formatted date string, or '' for invalid input.
1429
+ *
1430
+ * @example
1431
+ * monthDayStringNumeric(new Date(2011, 11, 15)); // '12/15'
1432
+ */
1433
+ export declare const monthDayStringNumeric: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
1434
+ //#endregion
1435
+ //#region src/utilities/noOpFnReturningFalse.d.ts
1436
+ type NoOpFnReturningFalse = typeof noOpFnReturningFalse;
1437
+ /**
1438
+ * A function that does nothing and returns `false`. Useful as a default or
1439
+ * placeholder callback where `false` is expected.
1440
+ *
1441
+ * @returns `false`.
1442
+ *
1443
+ * @example
1444
+ * noOpFnReturningFalse(); // false
1445
+ */
1446
+ export declare const noOpFnReturningFalse: () => false;
1447
+ //#endregion
1448
+ //#region src/utilities/noOpFnReturningNull.d.ts
1449
+ type NoOpFnReturningNull = typeof noOpFnReturningNull;
1450
+ /**
1451
+ * A function that does nothing and returns `null`. Useful as a default or
1452
+ * placeholder callback where `null` is expected.
1453
+ *
1454
+ * @returns `null`.
1455
+ *
1456
+ * @example
1457
+ * noOpFnReturningNull(); // null
1458
+ */
1459
+ export declare const noOpFnReturningNull: () => null;
1460
+ //#endregion
1461
+ //#region src/utilities/parseDateString.d.ts
1462
+ /**
1463
+ * Loosely parses a human-entered date string into a Date at local midnight.
1464
+ * Accepts 'today' and 'tomorrow', month name prefixes (resolved to the next
1465
+ * 1st of that month), and common numeric and month-name formats, with a
1466
+ * native Date fallback for anything else.
1467
+ *
1468
+ * @param str - The date string to parse.
1469
+ * @returns The parsed Date at local midnight, or null if unparseable.
1470
+ *
1471
+ * @example
1472
+ * parseDateString('Jan 5, 2025'); // Date for 2025-01-05 at local midnight
1473
+ * parseDateString('garbage'); // null
1474
+ */
1475
+ export declare const parseDateString: (str: string) => Date | null;
1476
+ //#endregion
1477
+ //#region src/utilities/sessionDurationString.d.ts
1478
+ /**
1479
+ * A string representation of a duration for a user session. Assumes that
1480
+ * sessions may or may not be more than an hour. To prevent confusion all
1481
+ * times show hours, even those that are less than an hour.
1482
+ *
1483
+ * @param numberOfMilliseconds - The duration in milliseconds.
1484
+ * @returns The formatted duration string.
1485
+ *
1486
+ * @example
1487
+ * sessionDurationString(2342300); // '0:39:02'
1488
+ */
1489
+ export declare const sessionDurationString: (numberOfMilliseconds: number) => string;
1490
+ //#endregion
1491
+ //#region src/utilities/stripExtension.d.ts
1492
+ /**
1493
+ * Removes the file extension from a string.
1494
+ *
1495
+ * @param str - The string to remove the file extension from.
1496
+ * @returns The string without its file extension.
1497
+ *
1498
+ * @example
1499
+ * stripExtension('config.yml'); // 'config'
1500
+ * stripExtension('example.test.ts'); // 'example.test'
1501
+ */
1502
+ export declare const stripExtension: (str: string) => string;
1503
+ //#endregion
1504
+ //#region src/utilities/timeAgoString.d.ts
1505
+ type TimeAgoOptions = {
1506
+ nowAnchor?: Date;
1507
+ includeTime?: boolean;
1508
+ };
1509
+ /**
1510
+ * Shows time ago relative to current time, e.g. '< 1 minute ago',
1511
+ * '33 minutes ago', 'Today, 3:30 PM', 'Yesterday, 6:22 AM',
1512
+ * 'Nov 11, 11:32 AM', or 'Feb 23, 2020, 1:55 PM'. When includeTime is
1513
+ * false: 'Today', 'Yesterday', 'on Thursday', 'Nov 11', 'Feb 23, 2020'.
1514
+ *
1515
+ * NOTE: timeAgoString doesn't support multiple time zones since doing so
1516
+ * would complicate calculations for whether to use "Today" or "Yesterday".
1517
+ *
1518
+ * @param date - The date relative to now.
1519
+ * @param options - Formatting options.
1520
+ * @param options.nowAnchor - The date used to calculate relative to now. Defaults to the current date but can be overwritten for tests.
1521
+ * @param options.includeTime - Whether to include the time in the output. Defaults to true.
1522
+ * @returns The relative date string, or '' for invalid input.
1523
+ *
1524
+ * @example
1525
+ * timeAgoString(new Date(Date.now() - 30_000)); // '< 1 minute ago'
1526
+ */
1527
+ export declare const timeAgoString: (date: Date, { nowAnchor, includeTime }?: TimeAgoOptions) => string;
1528
+ //#endregion
1529
+ //#region src/utilities/timeOnlyString.d.ts
1530
+ /**
1531
+ * Converts a Date object into a time only string, e.g. '7:30 AM'.
1532
+ * Formats with the en-US locale.
1533
+ *
1534
+ * @param date - The Date to format; gracefully handles any value.
1535
+ * @param options - Formatting options.
1536
+ * @param options.timeZone - The time zone to display the time in. Defaults to the current time zone.
1537
+ * @returns The formatted time string, or '' for invalid input.
1538
+ *
1539
+ * @example
1540
+ * timeOnlyString(new Date(2011, 11, 15, 7, 30)); // '7:30 AM'
1541
+ */
1542
+ export declare const timeOnlyString: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
1543
+ //#endregion
1544
+ //#region src/utilities/tupleIncludes.d.ts
1545
+ /**
1546
+ * Checks if a tuple includes the given item, with type narrowing.
1547
+ *
1548
+ * @param tuple - The tuple to search.
1549
+ * @param item - The item to search for.
1550
+ * @returns True if the tuple includes the item, false otherwise.
1551
+ *
1552
+ * @example
1553
+ * const tuple = ['x', 'y'] as const;
1554
+ * tupleIncludes(tuple, 'x'); // true
1555
+ * tupleIncludes(tuple, 'z'); // false
1556
+ */
1557
+ export declare const tupleIncludes: <TTuple extends readonly TItem[], TItem>(tuple: TTuple, item: TItem) => item is TTuple[number];
1558
+ //#endregion
1559
+ export type { Arrayable, AsyncNoOpFn, AsyncOrSyncNoOpFn, DateOnlyStringOptions, DateTimeRoundedOverload, DeepMerged, Falsy, NestedNonNullable, Nil, Nilable, NilableArray, NoOpFn, NoOpFnReturningFalse, NoOpFnReturningNull, NonEmptyArray, NotNilable, Nullable, NullableProperties, TimeAgoOptions, TimeDuration, Truthy, Undefinable, WistiaDateTimeObject };
1560
+ //# sourceMappingURL=index.d.mts.map