@wistia/utils 1.1.0 → 1.3.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/CHANGELOG.md +12 -0
- package/README.md +2 -0
- package/dist/index.d.mts +47 -203
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +156 -192
- package/dist/index.mjs.map +1 -1
- package/llms-full.txt +39 -0
- package/llms.txt +2 -0
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/utils v1.
|
|
3
|
+
* @license @wistia/utils v1.3.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2023-2026, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { EmptyObject, Get, Paths, UnknownRecord } from "type-fest";
|
|
11
|
-
//#region src/guards/hasKey.d.ts
|
|
12
11
|
/**
|
|
13
12
|
* Curried function that tests if an input is an object
|
|
14
13
|
* _and_ that a key that was passed in is a property of that object.
|
|
@@ -25,8 +24,6 @@ import { EmptyObject, Get, Paths, UnknownRecord } from "type-fest";
|
|
|
25
24
|
* @category Records
|
|
26
25
|
*/
|
|
27
26
|
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
27
|
/**
|
|
31
28
|
* Checks if the provided value is an array.
|
|
32
29
|
*
|
|
@@ -40,8 +37,6 @@ export declare const hasKey: <Key extends string, Value>(value: unknown, key: Ke
|
|
|
40
37
|
* @category Arrays
|
|
41
38
|
*/
|
|
42
39
|
export declare const isArray: (value: unknown) => value is unknown[];
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/guards/isAsyncFunction.d.ts
|
|
45
40
|
/**
|
|
46
41
|
* Checks if the provided value is an async function.
|
|
47
42
|
*
|
|
@@ -63,8 +58,6 @@ export declare const isArray: (value: unknown) => value is unknown[];
|
|
|
63
58
|
* @category Primitives
|
|
64
59
|
*/
|
|
65
60
|
export declare const isAsyncFunction: (value: unknown) => value is (...args: unknown[]) => Promise<unknown>;
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/guards/isBigInt.d.ts
|
|
68
61
|
/**
|
|
69
62
|
* Checks if the provided value is a bigint.
|
|
70
63
|
*
|
|
@@ -78,8 +71,6 @@ export declare const isAsyncFunction: (value: unknown) => value is (...args: unk
|
|
|
78
71
|
* @category Primitives
|
|
79
72
|
*/
|
|
80
73
|
export declare const isBigInt: (value: unknown) => value is bigint;
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/guards/isBoolean.d.ts
|
|
83
74
|
/**
|
|
84
75
|
* Checks if the provided value is a boolean.
|
|
85
76
|
*
|
|
@@ -93,8 +84,6 @@ export declare const isBigInt: (value: unknown) => value is bigint;
|
|
|
93
84
|
* @category Primitives
|
|
94
85
|
*/
|
|
95
86
|
export declare const isBoolean: (value: unknown) => value is boolean;
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/guards/isDate.d.ts
|
|
98
87
|
/**
|
|
99
88
|
* Checks if the provided value is an instance of Date.
|
|
100
89
|
*
|
|
@@ -112,8 +101,6 @@ export declare const isBoolean: (value: unknown) => value is boolean;
|
|
|
112
101
|
* @category Primitives
|
|
113
102
|
*/
|
|
114
103
|
export declare const isDate: (value: unknown) => value is Date;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/guards/isEmptyArray.d.ts
|
|
117
104
|
/**
|
|
118
105
|
* Checks if the provided value is an empty array.
|
|
119
106
|
*
|
|
@@ -127,8 +114,6 @@ export declare const isDate: (value: unknown) => value is Date;
|
|
|
127
114
|
* @category Arrays
|
|
128
115
|
*/
|
|
129
116
|
export declare const isEmptyArray: (value: unknown) => value is never[];
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/guards/isEmptyRecord.d.ts
|
|
132
117
|
/**
|
|
133
118
|
* Checks if the provided value is an object with no own properties.
|
|
134
119
|
*
|
|
@@ -142,8 +127,6 @@ export declare const isEmptyArray: (value: unknown) => value is never[];
|
|
|
142
127
|
* @category Records
|
|
143
128
|
*/
|
|
144
129
|
export declare const isEmptyRecord: (value: unknown) => value is EmptyObject;
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/guards/isEmptyString.d.ts
|
|
147
130
|
/**
|
|
148
131
|
* Checks if the provided value is an empty string.
|
|
149
132
|
*
|
|
@@ -157,8 +140,6 @@ export declare const isEmptyRecord: (value: unknown) => value is EmptyObject;
|
|
|
157
140
|
* @category Strings
|
|
158
141
|
*/
|
|
159
142
|
export declare const isEmptyString: (value: unknown) => value is '';
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/guards/isError.d.ts
|
|
162
143
|
/**
|
|
163
144
|
* Checks if the provided value is an instance of Error.
|
|
164
145
|
*
|
|
@@ -175,8 +156,6 @@ export declare const isEmptyString: (value: unknown) => value is '';
|
|
|
175
156
|
* @category Primitives
|
|
176
157
|
*/
|
|
177
158
|
export declare const isError: (value: unknown) => value is Error;
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/types/Falsy.d.ts
|
|
180
159
|
/**
|
|
181
160
|
* Represents a value that is falsy.
|
|
182
161
|
*
|
|
@@ -184,8 +163,6 @@ export declare const isError: (value: unknown) => value is Error;
|
|
|
184
163
|
* type X = Falsy; // number | '' | 0n | false | null | undefined
|
|
185
164
|
*/
|
|
186
165
|
type Falsy = typeof NaN | '' | 0n | false | null | undefined;
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/guards/isFalsy.d.ts
|
|
189
166
|
/**
|
|
190
167
|
* Checks if the provided value is falsy.
|
|
191
168
|
*
|
|
@@ -203,8 +180,6 @@ type Falsy = typeof NaN | '' | 0n | false | null | undefined;
|
|
|
203
180
|
* @category Truthy / falsy
|
|
204
181
|
*/
|
|
205
182
|
export declare const isFalsy: (value: unknown) => value is Falsy;
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/guards/isFiniteNumber.d.ts
|
|
208
183
|
/**
|
|
209
184
|
* Checks if the provided value is a finite number.
|
|
210
185
|
*
|
|
@@ -218,8 +193,6 @@ export declare const isFalsy: (value: unknown) => value is Falsy;
|
|
|
218
193
|
* @category Primitives
|
|
219
194
|
*/
|
|
220
195
|
export declare const isFiniteNumber: (value: unknown) => value is number;
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/guards/isFunction.d.ts
|
|
223
196
|
/**
|
|
224
197
|
* Checks if the provided value is a function.
|
|
225
198
|
*
|
|
@@ -233,8 +206,6 @@ export declare const isFiniteNumber: (value: unknown) => value is number;
|
|
|
233
206
|
* @category Primitives
|
|
234
207
|
*/
|
|
235
208
|
export declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/guards/isHtmlButtonElement.d.ts
|
|
238
209
|
/**
|
|
239
210
|
* Checks if the provided value is an HTMLButtonElement.
|
|
240
211
|
*
|
|
@@ -248,8 +219,6 @@ export declare const isFunction: (value: unknown) => value is (...args: unknown[
|
|
|
248
219
|
* @category DOM
|
|
249
220
|
*/
|
|
250
221
|
export declare const isHtmlButtonElement: (value: unknown) => value is HTMLButtonElement;
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region src/guards/isHtmlElement.d.ts
|
|
253
222
|
/**
|
|
254
223
|
* Checks if the provided value is an HTMLElement.
|
|
255
224
|
*
|
|
@@ -263,8 +232,6 @@ export declare const isHtmlButtonElement: (value: unknown) => value is HTMLButto
|
|
|
263
232
|
* @category DOM
|
|
264
233
|
*/
|
|
265
234
|
export declare const isHtmlElement: (value: unknown) => value is HTMLElement;
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region src/guards/isHtmlInputElement.d.ts
|
|
268
235
|
/**
|
|
269
236
|
* Checks if the provided value is an HTMLInputElement.
|
|
270
237
|
*
|
|
@@ -278,8 +245,6 @@ export declare const isHtmlElement: (value: unknown) => value is HTMLElement;
|
|
|
278
245
|
* @category DOM
|
|
279
246
|
*/
|
|
280
247
|
export declare const isHtmlInputElement: (value: unknown) => value is HTMLInputElement;
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/guards/isHtmlVideoElement.d.ts
|
|
283
248
|
/**
|
|
284
249
|
* Checks if the provided value is an HTMLVideoElement.
|
|
285
250
|
*
|
|
@@ -293,8 +258,6 @@ export declare const isHtmlInputElement: (value: unknown) => value is HTMLInputE
|
|
|
293
258
|
* @category DOM
|
|
294
259
|
*/
|
|
295
260
|
export declare const isHtmlVideoElement: (value: unknown) => value is HTMLVideoElement;
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/guards/isInteger.d.ts
|
|
298
261
|
/**
|
|
299
262
|
* Checks if the provided value is an integer.
|
|
300
263
|
*
|
|
@@ -312,8 +275,6 @@ export declare const isHtmlVideoElement: (value: unknown) => value is HTMLVideoE
|
|
|
312
275
|
* @category Primitives
|
|
313
276
|
*/
|
|
314
277
|
export declare const isInteger: (value: unknown) => value is number;
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region src/guards/isIterable.d.ts
|
|
317
278
|
/**
|
|
318
279
|
* Checks if the provided value implements the iterable protocol.
|
|
319
280
|
*
|
|
@@ -331,8 +292,6 @@ export declare const isInteger: (value: unknown) => value is number;
|
|
|
331
292
|
* @category Primitives
|
|
332
293
|
*/
|
|
333
294
|
export declare const isIterable: (value: unknown) => value is Iterable<unknown>;
|
|
334
|
-
//#endregion
|
|
335
|
-
//#region src/guards/isMap.d.ts
|
|
336
295
|
/**
|
|
337
296
|
* Checks if the provided value is an instance of Map.
|
|
338
297
|
*
|
|
@@ -349,8 +308,6 @@ export declare const isIterable: (value: unknown) => value is Iterable<unknown>;
|
|
|
349
308
|
* @category Primitives
|
|
350
309
|
*/
|
|
351
310
|
export declare const isMap: (value: unknown) => value is Map<unknown, unknown>;
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region src/guards/isMouseEvent.d.ts
|
|
354
311
|
/**
|
|
355
312
|
* Checks if the provided value is a MouseEvent.
|
|
356
313
|
*
|
|
@@ -364,8 +321,6 @@ export declare const isMap: (value: unknown) => value is Map<unknown, unknown>;
|
|
|
364
321
|
* @category DOM
|
|
365
322
|
*/
|
|
366
323
|
export declare const isMouseEvent: (value: unknown) => value is MouseEvent;
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region src/guards/isNaN.d.ts
|
|
369
324
|
/**
|
|
370
325
|
* Checks if the provided value is NaN (Not a Number).
|
|
371
326
|
*
|
|
@@ -383,8 +338,6 @@ export declare const isMouseEvent: (value: unknown) => value is MouseEvent;
|
|
|
383
338
|
* @category Primitives
|
|
384
339
|
*/
|
|
385
340
|
export declare const isNaN: (value: unknown) => value is number;
|
|
386
|
-
//#endregion
|
|
387
|
-
//#region src/types/Nil.d.ts
|
|
388
341
|
/**
|
|
389
342
|
* Represents a value that is either null or undefined.
|
|
390
343
|
*
|
|
@@ -392,8 +345,6 @@ export declare const isNaN: (value: unknown) => value is number;
|
|
|
392
345
|
* type X = Nil; // null | undefined
|
|
393
346
|
*/
|
|
394
347
|
type Nil = null | undefined;
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/guards/isNil.d.ts
|
|
397
348
|
/**
|
|
398
349
|
* Checks if the provided value is null or undefined.
|
|
399
350
|
*
|
|
@@ -407,8 +358,6 @@ type Nil = null | undefined;
|
|
|
407
358
|
* @category Primitives
|
|
408
359
|
*/
|
|
409
360
|
export declare const isNil: (value: unknown) => value is Nil;
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region src/guards/isNonBlankString.d.ts
|
|
412
361
|
/**
|
|
413
362
|
* Checks if the provided value is a non-blank string (not empty and not whitespace-only).
|
|
414
363
|
* Use {@link isNonEmptyString} when whitespace-only strings are acceptable (e.g. preserving
|
|
@@ -424,8 +373,6 @@ export declare const isNil: (value: unknown) => value is Nil;
|
|
|
424
373
|
* @category Strings
|
|
425
374
|
*/
|
|
426
375
|
export declare const isNonBlankString: (value: unknown) => value is string;
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/types/Nilable.d.ts
|
|
429
376
|
/**
|
|
430
377
|
* Represents a value that can be of type `A` or be null/undefined.
|
|
431
378
|
*
|
|
@@ -435,8 +382,6 @@ export declare const isNonBlankString: (value: unknown) => value is string;
|
|
|
435
382
|
* type Maybe = Nilable<string>; // string | null | undefined
|
|
436
383
|
*/
|
|
437
384
|
type Nilable<A> = A | Nil;
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region src/types/NonEmptyArray.d.ts
|
|
440
385
|
/**
|
|
441
386
|
* Represents an array that contains at least one element.
|
|
442
387
|
*
|
|
@@ -446,8 +391,6 @@ type Nilable<A> = A | Nil;
|
|
|
446
391
|
* type Ids = NonEmptyArray<number>; // [number, ...number[]]
|
|
447
392
|
*/
|
|
448
393
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
449
|
-
//#endregion
|
|
450
|
-
//#region src/guards/isNonEmptyArray.d.ts
|
|
451
394
|
/**
|
|
452
395
|
* Checks if the provided value is a non-empty array.
|
|
453
396
|
*
|
|
@@ -461,8 +404,6 @@ type NonEmptyArray<T> = [T, ...T[]];
|
|
|
461
404
|
* @category Arrays
|
|
462
405
|
*/
|
|
463
406
|
export declare const isNonEmptyArray: <T>(value: Nilable<T[] | UnknownRecord>) => value is NonEmptyArray<T>;
|
|
464
|
-
//#endregion
|
|
465
|
-
//#region src/guards/isNonEmptyRecord.d.ts
|
|
466
407
|
/**
|
|
467
408
|
* Checks if the provided value is an object with at least one own property.
|
|
468
409
|
*
|
|
@@ -476,8 +417,6 @@ export declare const isNonEmptyArray: <T>(value: Nilable<T[] | UnknownRecord>) =
|
|
|
476
417
|
* @category Records
|
|
477
418
|
*/
|
|
478
419
|
export declare const isNonEmptyRecord: (value: unknown) => value is Record<string, unknown>;
|
|
479
|
-
//#endregion
|
|
480
|
-
//#region src/guards/isNonEmptyString.d.ts
|
|
481
420
|
/**
|
|
482
421
|
* Checks if the provided value is a non-empty string. Whitespace-only strings like `" "` pass.
|
|
483
422
|
* Use {@link isNonBlankString} when whitespace-only strings should be rejected (e.g. user input
|
|
@@ -493,8 +432,6 @@ export declare const isNonEmptyRecord: (value: unknown) => value is Record<strin
|
|
|
493
432
|
* @category Strings
|
|
494
433
|
*/
|
|
495
434
|
export declare const isNonEmptyString: (value: unknown) => value is string;
|
|
496
|
-
//#endregion
|
|
497
|
-
//#region src/guards/isNonNaNNumber.d.ts
|
|
498
435
|
/**
|
|
499
436
|
* Checks if the provided value is a number that is not NaN.
|
|
500
437
|
*
|
|
@@ -508,8 +445,6 @@ export declare const isNonEmptyString: (value: unknown) => value is string;
|
|
|
508
445
|
* @category Primitives
|
|
509
446
|
*/
|
|
510
447
|
export declare const isNonNaNNumber: (value: unknown) => value is number;
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region src/guards/isNotArray.d.ts
|
|
513
448
|
/**
|
|
514
449
|
* Checks if the provided value is not an array.
|
|
515
450
|
*
|
|
@@ -523,8 +458,6 @@ export declare const isNonNaNNumber: (value: unknown) => value is number;
|
|
|
523
458
|
* @category Negated
|
|
524
459
|
*/
|
|
525
460
|
export declare const isNotArray: (value: unknown) => value is Exclude<unknown, unknown[]>;
|
|
526
|
-
//#endregion
|
|
527
|
-
//#region src/guards/isNotBoolean.d.ts
|
|
528
461
|
/**
|
|
529
462
|
* Checks if the provided value is not a boolean.
|
|
530
463
|
*
|
|
@@ -538,8 +471,6 @@ export declare const isNotArray: (value: unknown) => value is Exclude<unknown, u
|
|
|
538
471
|
* @category Negated
|
|
539
472
|
*/
|
|
540
473
|
export declare const isNotBoolean: (value: unknown) => value is Exclude<unknown, boolean>;
|
|
541
|
-
//#endregion
|
|
542
|
-
//#region src/guards/isNotFunction.d.ts
|
|
543
474
|
/**
|
|
544
475
|
* Checks if the provided value is not a function.
|
|
545
476
|
*
|
|
@@ -553,8 +484,6 @@ export declare const isNotBoolean: (value: unknown) => value is Exclude<unknown,
|
|
|
553
484
|
* @category Negated
|
|
554
485
|
*/
|
|
555
486
|
export declare const isNotFunction: (value: unknown) => value is Exclude<unknown, (...args: unknown[]) => unknown>;
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region src/guards/isNotNil.d.ts
|
|
558
487
|
/**
|
|
559
488
|
* Checks if the provided value is neither null nor undefined.
|
|
560
489
|
*
|
|
@@ -575,8 +504,6 @@ export declare const isNotFunction: (value: unknown) => value is Exclude<unknown
|
|
|
575
504
|
* @category Negated
|
|
576
505
|
*/
|
|
577
506
|
export declare const isNotNil: <T>(value: Nil | T) => value is T;
|
|
578
|
-
//#endregion
|
|
579
|
-
//#region src/guards/isNotNull.d.ts
|
|
580
507
|
/**
|
|
581
508
|
* Checks if the provided value is not null.
|
|
582
509
|
*
|
|
@@ -590,8 +517,6 @@ export declare const isNotNil: <T>(value: Nil | T) => value is T;
|
|
|
590
517
|
* @category Negated
|
|
591
518
|
*/
|
|
592
519
|
export declare const isNotNull: <T>(value: unknown) => value is Exclude<T, null>;
|
|
593
|
-
//#endregion
|
|
594
|
-
//#region src/guards/isNotNumber.d.ts
|
|
595
520
|
/**
|
|
596
521
|
* Checks if the provided value is not a number.
|
|
597
522
|
*
|
|
@@ -605,8 +530,6 @@ export declare const isNotNull: <T>(value: unknown) => value is Exclude<T, null>
|
|
|
605
530
|
* @category Negated
|
|
606
531
|
*/
|
|
607
532
|
export declare const isNotNumber: (value: unknown) => value is Exclude<unknown, number>;
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region src/guards/isNotRecord.d.ts
|
|
610
533
|
/**
|
|
611
534
|
* Checks if the provided value is not an object.
|
|
612
535
|
*
|
|
@@ -620,8 +543,6 @@ export declare const isNotNumber: (value: unknown) => value is Exclude<unknown,
|
|
|
620
543
|
* @category Negated
|
|
621
544
|
*/
|
|
622
545
|
export declare const isNotRecord: (value: unknown) => value is Exclude<unknown, Record<string, unknown>>;
|
|
623
|
-
//#endregion
|
|
624
|
-
//#region src/guards/isNotString.d.ts
|
|
625
546
|
/**
|
|
626
547
|
* Checks if the provided value is not a string.
|
|
627
548
|
*
|
|
@@ -635,8 +556,6 @@ export declare const isNotRecord: (value: unknown) => value is Exclude<unknown,
|
|
|
635
556
|
* @category Negated
|
|
636
557
|
*/
|
|
637
558
|
export declare const isNotString: (value: unknown) => value is Exclude<unknown, string>;
|
|
638
|
-
//#endregion
|
|
639
|
-
//#region src/types/Undefinable.d.ts
|
|
640
559
|
/**
|
|
641
560
|
* Represents a value that can be of type `A` or `undefined`.
|
|
642
561
|
*
|
|
@@ -646,8 +565,6 @@ export declare const isNotString: (value: unknown) => value is Exclude<unknown,
|
|
|
646
565
|
* type X = Undefinable<string>; // string | undefined
|
|
647
566
|
*/
|
|
648
567
|
type Undefinable<A> = A | undefined;
|
|
649
|
-
//#endregion
|
|
650
|
-
//#region src/guards/isNotUndefined.d.ts
|
|
651
568
|
/**
|
|
652
569
|
* Checks if the provided value is not undefined.
|
|
653
570
|
*
|
|
@@ -661,8 +578,6 @@ type Undefinable<A> = A | undefined;
|
|
|
661
578
|
* @category Negated
|
|
662
579
|
*/
|
|
663
580
|
export declare const isNotUndefined: <T>(value: Undefinable<T>) => value is Exclude<T, undefined>;
|
|
664
|
-
//#endregion
|
|
665
|
-
//#region src/guards/isNotVoid.d.ts
|
|
666
581
|
/**
|
|
667
582
|
* Checks if the provided value is not void.
|
|
668
583
|
*
|
|
@@ -676,8 +591,6 @@ export declare const isNotUndefined: <T>(value: Undefinable<T>) => value is Excl
|
|
|
676
591
|
* @category Negated
|
|
677
592
|
*/
|
|
678
593
|
export declare const isNotVoid: (value: unknown) => value is Exclude<unknown, void>;
|
|
679
|
-
//#endregion
|
|
680
|
-
//#region src/guards/isNull.d.ts
|
|
681
594
|
/**
|
|
682
595
|
* Checks if the provided value is null.
|
|
683
596
|
*
|
|
@@ -691,8 +604,6 @@ export declare const isNotVoid: (value: unknown) => value is Exclude<unknown, vo
|
|
|
691
604
|
* @category Primitives
|
|
692
605
|
*/
|
|
693
606
|
export declare const isNull: (value: unknown) => value is null;
|
|
694
|
-
//#endregion
|
|
695
|
-
//#region src/guards/isNumber.d.ts
|
|
696
607
|
/**
|
|
697
608
|
* Checks if the provided value is a number.
|
|
698
609
|
*
|
|
@@ -710,8 +621,6 @@ export declare const isNull: (value: unknown) => value is null;
|
|
|
710
621
|
* @category Primitives
|
|
711
622
|
*/
|
|
712
623
|
export declare const isNumber: (value: unknown) => value is number;
|
|
713
|
-
//#endregion
|
|
714
|
-
//#region src/guards/isPlainObject.d.ts
|
|
715
624
|
/**
|
|
716
625
|
* Checks if the provided value is a plain object created with `{}` or `Object.create(null)`.
|
|
717
626
|
* Returns false for arrays, `Date`, `Map`, `RegExp`, boxed primitives, and class instances.
|
|
@@ -726,8 +635,6 @@ export declare const isNumber: (value: unknown) => value is number;
|
|
|
726
635
|
* @category Records
|
|
727
636
|
*/
|
|
728
637
|
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
729
|
-
//#endregion
|
|
730
|
-
//#region src/guards/isPromise.d.ts
|
|
731
638
|
/**
|
|
732
639
|
* Checks if the provided value is a Promise, including promise-like objects
|
|
733
640
|
* that implement `then`, `catch`, and `finally`.
|
|
@@ -747,8 +654,6 @@ export declare const isPlainObject: (value: unknown) => value is Record<string,
|
|
|
747
654
|
* @category Primitives
|
|
748
655
|
*/
|
|
749
656
|
export declare const isPromise: (value: unknown) => value is Promise<unknown>;
|
|
750
|
-
//#endregion
|
|
751
|
-
//#region src/guards/isRecord.d.ts
|
|
752
657
|
/**
|
|
753
658
|
* Checks if the provided value is a non-null object that is not an array.
|
|
754
659
|
*
|
|
@@ -762,8 +667,6 @@ export declare const isPromise: (value: unknown) => value is Promise<unknown>;
|
|
|
762
667
|
* @category Records
|
|
763
668
|
*/
|
|
764
669
|
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
765
|
-
//#endregion
|
|
766
|
-
//#region src/guards/isRegExp.d.ts
|
|
767
670
|
/**
|
|
768
671
|
* Checks if the provided value is an instance of RegExp.
|
|
769
672
|
*
|
|
@@ -777,8 +680,6 @@ export declare const isRecord: (value: unknown) => value is Record<string, unkno
|
|
|
777
680
|
* @category Primitives
|
|
778
681
|
*/
|
|
779
682
|
export declare const isRegExp: (value: unknown) => value is RegExp;
|
|
780
|
-
//#endregion
|
|
781
|
-
//#region src/guards/isSet.d.ts
|
|
782
683
|
/**
|
|
783
684
|
* Checks if the provided value is an instance of Set.
|
|
784
685
|
*
|
|
@@ -795,8 +696,6 @@ export declare const isRegExp: (value: unknown) => value is RegExp;
|
|
|
795
696
|
* @category Primitives
|
|
796
697
|
*/
|
|
797
698
|
export declare const isSet: (value: unknown) => value is Set<unknown>;
|
|
798
|
-
//#endregion
|
|
799
|
-
//#region src/guards/isString.d.ts
|
|
800
699
|
/**
|
|
801
700
|
* Checks if the provided value is a string.
|
|
802
701
|
*
|
|
@@ -810,8 +709,6 @@ export declare const isSet: (value: unknown) => value is Set<unknown>;
|
|
|
810
709
|
* @category Primitives
|
|
811
710
|
*/
|
|
812
711
|
export declare const isString: (value: unknown) => value is string;
|
|
813
|
-
//#endregion
|
|
814
|
-
//#region src/guards/isSvgElement.d.ts
|
|
815
712
|
/**
|
|
816
713
|
* Checks if the provided value is an SVGElement.
|
|
817
714
|
*
|
|
@@ -825,8 +722,6 @@ export declare const isString: (value: unknown) => value is string;
|
|
|
825
722
|
* @category DOM
|
|
826
723
|
*/
|
|
827
724
|
export declare const isSvgElement: (value: unknown) => value is SVGElement;
|
|
828
|
-
//#endregion
|
|
829
|
-
//#region src/guards/isSymbol.d.ts
|
|
830
725
|
/**
|
|
831
726
|
* Checks if the provided value is a symbol.
|
|
832
727
|
*
|
|
@@ -840,8 +735,6 @@ export declare const isSvgElement: (value: unknown) => value is SVGElement;
|
|
|
840
735
|
* @category Primitives
|
|
841
736
|
*/
|
|
842
737
|
export declare const isSymbol: (value: unknown) => value is symbol;
|
|
843
|
-
//#endregion
|
|
844
|
-
//#region src/guards/isTextNode.d.ts
|
|
845
738
|
/**
|
|
846
739
|
* Checks if the provided value is a Text node.
|
|
847
740
|
*
|
|
@@ -855,8 +748,6 @@ export declare const isSymbol: (value: unknown) => value is symbol;
|
|
|
855
748
|
* @category DOM
|
|
856
749
|
*/
|
|
857
750
|
export declare const isTextNode: (value: unknown) => value is Text;
|
|
858
|
-
//#endregion
|
|
859
|
-
//#region src/guards/isTruthy.d.ts
|
|
860
751
|
/**
|
|
861
752
|
* Checks if the provided value is truthy.
|
|
862
753
|
*
|
|
@@ -874,8 +765,6 @@ export declare const isTextNode: (value: unknown) => value is Text;
|
|
|
874
765
|
* @category Truthy / falsy
|
|
875
766
|
*/
|
|
876
767
|
export declare const isTruthy: (value: unknown) => boolean;
|
|
877
|
-
//#endregion
|
|
878
|
-
//#region src/guards/isUndefined.d.ts
|
|
879
768
|
/**
|
|
880
769
|
* Checks if the provided value is undefined.
|
|
881
770
|
*
|
|
@@ -889,8 +778,6 @@ export declare const isTruthy: (value: unknown) => boolean;
|
|
|
889
778
|
* @category Primitives
|
|
890
779
|
*/
|
|
891
780
|
export declare const isUndefined: (value: unknown) => value is undefined;
|
|
892
|
-
//#endregion
|
|
893
|
-
//#region src/guards/isVoid.d.ts
|
|
894
781
|
/**
|
|
895
782
|
* Checks if the provided value is void.
|
|
896
783
|
*
|
|
@@ -904,8 +791,6 @@ export declare const isUndefined: (value: unknown) => value is undefined;
|
|
|
904
791
|
* @category Primitives
|
|
905
792
|
*/
|
|
906
793
|
export declare const isVoid: (value: unknown) => value is void;
|
|
907
|
-
//#endregion
|
|
908
|
-
//#region src/guards/isWeakMap.d.ts
|
|
909
794
|
/**
|
|
910
795
|
* Checks if the provided value is an instance of WeakMap.
|
|
911
796
|
*
|
|
@@ -923,8 +808,6 @@ export declare const isVoid: (value: unknown) => value is void;
|
|
|
923
808
|
* @category Primitives
|
|
924
809
|
*/
|
|
925
810
|
export declare const isWeakMap: (value: unknown) => value is WeakMap<WeakKey, unknown>;
|
|
926
|
-
//#endregion
|
|
927
|
-
//#region src/guards/isWeakSet.d.ts
|
|
928
811
|
/**
|
|
929
812
|
* Checks if the provided value is an instance of WeakSet.
|
|
930
813
|
*
|
|
@@ -942,8 +825,6 @@ export declare const isWeakMap: (value: unknown) => value is WeakMap<WeakKey, un
|
|
|
942
825
|
* @category Primitives
|
|
943
826
|
*/
|
|
944
827
|
export declare const isWeakSet: (value: unknown) => value is WeakSet<WeakKey>;
|
|
945
|
-
//#endregion
|
|
946
|
-
//#region src/guards/readonlyArrayIncludes.d.ts
|
|
947
828
|
/**
|
|
948
829
|
* Checks if a readonly array includes the given element, with type narrowing.
|
|
949
830
|
*
|
|
@@ -959,8 +840,6 @@ export declare const isWeakSet: (value: unknown) => value is WeakSet<WeakKey>;
|
|
|
959
840
|
* @category Arrays
|
|
960
841
|
*/
|
|
961
842
|
export declare const readonlyArrayIncludes: <T>(arr: readonly T[], elem: unknown) => elem is T;
|
|
962
|
-
//#endregion
|
|
963
|
-
//#region src/types/Arrayable.d.ts
|
|
964
843
|
/**
|
|
965
844
|
* Represents a value that can be of type `T` or an array of `T`.
|
|
966
845
|
*
|
|
@@ -970,8 +849,6 @@ export declare const readonlyArrayIncludes: <T>(arr: readonly T[], elem: unknown
|
|
|
970
849
|
* type Tags = Arrayable<string>; // string | string[]
|
|
971
850
|
*/
|
|
972
851
|
type Arrayable<T> = T | T[];
|
|
973
|
-
//#endregion
|
|
974
|
-
//#region src/types/NestedNonNullable.d.ts
|
|
975
852
|
/**
|
|
976
853
|
* Retrieves the type of a deeply nested property from an object while removing null and undefined.
|
|
977
854
|
*
|
|
@@ -990,8 +867,6 @@ type Arrayable<T> = T | T[];
|
|
|
990
867
|
* type Name = NestedNonNullable<User, 'profile.name'>; // string
|
|
991
868
|
*/
|
|
992
869
|
type NestedNonNullable<T, P extends Paths<T> & string> = NonNullable<Get<T, P>>;
|
|
993
|
-
//#endregion
|
|
994
|
-
//#region src/types/NilableArray.d.ts
|
|
995
870
|
/**
|
|
996
871
|
* Represents an array that can be null or undefined, and its elements can also be null or undefined.
|
|
997
872
|
*
|
|
@@ -1001,8 +876,6 @@ type NestedNonNullable<T, P extends Paths<T> & string> = NonNullable<Get<T, P>>;
|
|
|
1001
876
|
* type Items = NilableArray<string>; // (string | null | undefined)[] | null | undefined
|
|
1002
877
|
*/
|
|
1003
878
|
type NilableArray<T> = Nilable<Nilable<T>[]>;
|
|
1004
|
-
//#endregion
|
|
1005
|
-
//#region src/types/NotNilable.d.ts
|
|
1006
879
|
/**
|
|
1007
880
|
* Represents a value of type `A` that is guaranteed to be neither null nor undefined.
|
|
1008
881
|
*
|
|
@@ -1012,8 +885,6 @@ type NilableArray<T> = Nilable<Nilable<T>[]>;
|
|
|
1012
885
|
* type X = NotNilable<string | null | undefined>; // string
|
|
1013
886
|
*/
|
|
1014
887
|
type NotNilable<A> = Exclude<A, Nil>;
|
|
1015
|
-
//#endregion
|
|
1016
|
-
//#region src/types/Nullable.d.ts
|
|
1017
888
|
/**
|
|
1018
889
|
* Represents a value that can be of type `A` or `null`.
|
|
1019
890
|
*
|
|
@@ -1023,8 +894,6 @@ type NotNilable<A> = Exclude<A, Nil>;
|
|
|
1023
894
|
* type X = Nullable<string>; // string | null
|
|
1024
895
|
*/
|
|
1025
896
|
type Nullable<A> = A | null;
|
|
1026
|
-
//#endregion
|
|
1027
|
-
//#region src/types/NullableProperties.d.ts
|
|
1028
897
|
/**
|
|
1029
898
|
* Makes every property of a record nullable.
|
|
1030
899
|
*
|
|
@@ -1035,8 +904,6 @@ type Nullable<A> = A | null;
|
|
|
1035
904
|
* type X = NullableProperties<User>; // { name: string | null; age: number | null }
|
|
1036
905
|
*/
|
|
1037
906
|
type NullableProperties<T extends UnknownRecord> = { [Key in keyof T]: Nullable<T[Key]>; };
|
|
1038
|
-
//#endregion
|
|
1039
|
-
//#region src/types/Truthy.d.ts
|
|
1040
907
|
/**
|
|
1041
908
|
* Represents a value that is truthy.
|
|
1042
909
|
*
|
|
@@ -1046,8 +913,6 @@ type NullableProperties<T extends UnknownRecord> = { [Key in keyof T]: Nullable<
|
|
|
1046
913
|
* type X = Truthy<string | 0 | null>; // string
|
|
1047
914
|
*/
|
|
1048
915
|
type Truthy<T> = Exclude<T, Falsy>;
|
|
1049
|
-
//#endregion
|
|
1050
|
-
//#region src/utilities/noOpFn.d.ts
|
|
1051
916
|
type NoOpFn = typeof noOpFn;
|
|
1052
917
|
/**
|
|
1053
918
|
* A function that does nothing. Useful as a default or placeholder callback.
|
|
@@ -1058,8 +923,6 @@ type NoOpFn = typeof noOpFn;
|
|
|
1058
923
|
* noOpFn(); // undefined
|
|
1059
924
|
*/
|
|
1060
925
|
export declare const noOpFn: () => void;
|
|
1061
|
-
//#endregion
|
|
1062
|
-
//#region src/utilities/asyncNoOpFn.d.ts
|
|
1063
926
|
type AsyncNoOpFn = typeof asyncNoOpFn;
|
|
1064
927
|
type AsyncOrSyncNoOpFn = AsyncNoOpFn | NoOpFn;
|
|
1065
928
|
/**
|
|
@@ -1072,8 +935,6 @@ type AsyncOrSyncNoOpFn = AsyncNoOpFn | NoOpFn;
|
|
|
1072
935
|
* await asyncNoOpFn(); // undefined
|
|
1073
936
|
*/
|
|
1074
937
|
export declare const asyncNoOpFn: () => Promise<void>;
|
|
1075
|
-
//#endregion
|
|
1076
|
-
//#region src/utilities/buildTimeDuration.d.ts
|
|
1077
938
|
type TimeDuration = {
|
|
1078
939
|
seconds: number;
|
|
1079
940
|
minutes: number;
|
|
@@ -1089,8 +950,6 @@ type TimeDuration = {
|
|
|
1089
950
|
* buildTimeDuration(3723000); // { hours: 1, minutes: 2, seconds: 3 }
|
|
1090
951
|
*/
|
|
1091
952
|
export declare const buildTimeDuration: (numberOfMilliseconds: number) => TimeDuration;
|
|
1092
|
-
//#endregion
|
|
1093
|
-
//#region src/utilities/coerceToBoolean.d.ts
|
|
1094
953
|
/**
|
|
1095
954
|
* Converts the boolean string values 'true' and 'false' into the
|
|
1096
955
|
* corresponding boolean. Any other value is coerced with `Boolean()`.
|
|
@@ -1104,8 +963,6 @@ export declare const buildTimeDuration: (numberOfMilliseconds: number) => TimeDu
|
|
|
1104
963
|
* coerceToBoolean(0); // false
|
|
1105
964
|
*/
|
|
1106
965
|
export declare const coerceToBoolean: (value: unknown) => boolean;
|
|
1107
|
-
//#endregion
|
|
1108
|
-
//#region src/utilities/dateOnlyString.d.ts
|
|
1109
966
|
type DateOnlyStringOptions = {
|
|
1110
967
|
timeZone?: string;
|
|
1111
968
|
/**
|
|
@@ -1128,8 +985,6 @@ type DateOnlyStringOptions = {
|
|
|
1128
985
|
* dateOnlyString(new Date(2011, 11, 15)); // 'Dec 15, 2011'
|
|
1129
986
|
*/
|
|
1130
987
|
export declare const dateOnlyString: (date: unknown, { timeZone, omitYear }?: DateOnlyStringOptions) => string;
|
|
1131
|
-
//#endregion
|
|
1132
|
-
//#region src/utilities/dateOnlyISOString.d.ts
|
|
1133
988
|
/**
|
|
1134
989
|
* Converts a Date object into a date only string formatted to ISO 8601,
|
|
1135
990
|
* e.g. '2021-06-03'.
|
|
@@ -1143,8 +998,6 @@ export declare const dateOnlyString: (date: unknown, { timeZone, omitYear }?: Da
|
|
|
1143
998
|
* dateOnlyISOString(new Date(2011, 11, 15)); // '2011-12-15'
|
|
1144
999
|
*/
|
|
1145
1000
|
export declare const dateOnlyISOString: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
|
|
1146
|
-
//#endregion
|
|
1147
|
-
//#region src/utilities/dateOnlyStringForSentence.d.ts
|
|
1148
1001
|
/**
|
|
1149
1002
|
* Converts a Date object into a date only string for use in a sentence,
|
|
1150
1003
|
* e.g. 'June 3, 2021'. Formats with the en-US locale.
|
|
@@ -1158,8 +1011,6 @@ export declare const dateOnlyISOString: (date: unknown, { timeZone }?: DateOnlyS
|
|
|
1158
1011
|
* dateOnlyStringForSentence(new Date(2011, 11, 15)); // 'December 15, 2011'
|
|
1159
1012
|
*/
|
|
1160
1013
|
export declare const dateOnlyStringForSentence: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
|
|
1161
|
-
//#endregion
|
|
1162
|
-
//#region src/utilities/dateOnlyStringNumeric.d.ts
|
|
1163
1014
|
/**
|
|
1164
1015
|
* Converts a Date object into a date only string formatted numerically,
|
|
1165
1016
|
* e.g. '06/03/2021'. Formats with the en-US locale.
|
|
@@ -1173,8 +1024,6 @@ export declare const dateOnlyStringForSentence: (date: unknown, { timeZone }?: D
|
|
|
1173
1024
|
* dateOnlyStringNumeric(new Date(2011, 11, 15)); // '12/15/2011'
|
|
1174
1025
|
*/
|
|
1175
1026
|
export declare const dateOnlyStringNumeric: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
|
|
1176
|
-
//#endregion
|
|
1177
|
-
//#region src/utilities/dateTimeRounded.d.ts
|
|
1178
1027
|
type DateTimeRoundedOverload = {
|
|
1179
1028
|
(dateTime: Date, toISOString?: true): string | null;
|
|
1180
1029
|
(dateTime: Date, toISOString: false): Date | null;
|
|
@@ -1191,8 +1040,6 @@ type DateTimeRoundedOverload = {
|
|
|
1191
1040
|
* dateTimeRounded(new Date(2015, 10, 7, 0, 40), false); // new Date(2015, 10, 7, 1, 0)
|
|
1192
1041
|
*/
|
|
1193
1042
|
export declare const dateTimeRounded: DateTimeRoundedOverload;
|
|
1194
|
-
//#endregion
|
|
1195
|
-
//#region src/utilities/dateTimeString.d.ts
|
|
1196
1043
|
/**
|
|
1197
1044
|
* Converts a Date, timestamp, or date string into a date and time string,
|
|
1198
1045
|
* e.g. 'Jun 3, 2021, 11:52 AM'. Formats with the en-US locale.
|
|
@@ -1210,8 +1057,6 @@ export declare const dateTimeRounded: DateTimeRoundedOverload;
|
|
|
1210
1057
|
* dateTimeString(new Date(2011, 11, 15, 7, 30)); // 'Dec 15, 2011, 7:30 AM'
|
|
1211
1058
|
*/
|
|
1212
1059
|
export declare const dateTimeString: (date: Date | number | string | null | undefined, { timeZone, omitYear }?: DateOnlyStringOptions) => string;
|
|
1213
|
-
//#endregion
|
|
1214
|
-
//#region src/utilities/dateTimeStringForSentence.d.ts
|
|
1215
1060
|
/**
|
|
1216
1061
|
* Converts a Date object into a date and time string for use in a sentence,
|
|
1217
1062
|
* e.g. 'June 3, 2021, 11:52 AM'. Formats with the en-US locale.
|
|
@@ -1228,8 +1073,6 @@ export declare const dateTimeString: (date: Date | number | string | null | unde
|
|
|
1228
1073
|
* dateTimeStringForSentence(new Date(2011, 11, 15, 7, 30)); // 'December 15, 2011, 7:30 AM'
|
|
1229
1074
|
*/
|
|
1230
1075
|
export declare const dateTimeStringForSentence: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
|
|
1231
|
-
//#endregion
|
|
1232
|
-
//#region src/utilities/dateToDateTime.d.ts
|
|
1233
1076
|
type WistiaDateTimeObject = {
|
|
1234
1077
|
minutes: number;
|
|
1235
1078
|
hours: number;
|
|
@@ -1248,8 +1091,6 @@ type WistiaDateTimeObject = {
|
|
|
1248
1091
|
* // { year: 2011, month: 11, dayOfMonth: 15, hours: 3, minutes: 10 }
|
|
1249
1092
|
*/
|
|
1250
1093
|
export declare const dateToDateTime: (date: Date | null | undefined) => WistiaDateTimeObject | null;
|
|
1251
|
-
//#endregion
|
|
1252
|
-
//#region src/utilities/dateTimeToDate.d.ts
|
|
1253
1094
|
/**
|
|
1254
1095
|
* Converts a plain object of date and time parts into a Date object.
|
|
1255
1096
|
*
|
|
@@ -1261,8 +1102,6 @@ export declare const dateToDateTime: (date: Date | null | undefined) => WistiaDa
|
|
|
1261
1102
|
* // new Date(2015, 10, 7, 4, 15)
|
|
1262
1103
|
*/
|
|
1263
1104
|
export declare const dateTimeToDate: (dateTime: Partial<WistiaDateTimeObject> | null | undefined) => Date | null;
|
|
1264
|
-
//#endregion
|
|
1265
|
-
//#region src/utilities/dateTimeToISO.d.ts
|
|
1266
1105
|
/**
|
|
1267
1106
|
* Converts a plain object of date and time parts into an ISO-8601 string.
|
|
1268
1107
|
*
|
|
@@ -1274,8 +1113,6 @@ export declare const dateTimeToDate: (dateTime: Partial<WistiaDateTimeObject> |
|
|
|
1274
1113
|
* // '2015-11-07T04:15:00.000Z' (in UTC)
|
|
1275
1114
|
*/
|
|
1276
1115
|
export declare const dateTimeToISO: (dateTime: Partial<WistiaDateTimeObject>) => string | null;
|
|
1277
|
-
//#endregion
|
|
1278
|
-
//#region src/utilities/dateUTCOffset.d.ts
|
|
1279
1116
|
/**
|
|
1280
1117
|
* Given a date, shows the UTC offset of the current time zone, e.g. '+02:00'.
|
|
1281
1118
|
*
|
|
@@ -1286,8 +1123,6 @@ export declare const dateTimeToISO: (dateTime: Partial<WistiaDateTimeObject>) =>
|
|
|
1286
1123
|
* dateUTCOffset(new Date(2011, 11, 15)); // '+00:00' (when run in UTC)
|
|
1287
1124
|
*/
|
|
1288
1125
|
export declare const dateUTCOffset: (date: Date) => string;
|
|
1289
|
-
//#endregion
|
|
1290
|
-
//#region src/utilities/dayOfWeekString.d.ts
|
|
1291
1126
|
/**
|
|
1292
1127
|
* Converts a Date object into a day of the week string, e.g. 'Thursday'.
|
|
1293
1128
|
* Formats with the en-US locale.
|
|
@@ -1301,8 +1136,6 @@ export declare const dateUTCOffset: (date: Date) => string;
|
|
|
1301
1136
|
* dayOfWeekString(new Date(2011, 11, 15)); // 'Thursday'
|
|
1302
1137
|
*/
|
|
1303
1138
|
export declare const dayOfWeekString: (date: Date | null, { timeZone }?: DateOnlyStringOptions) => string;
|
|
1304
|
-
//#endregion
|
|
1305
|
-
//#region src/utilities/deepMerge.d.ts
|
|
1306
1139
|
type AllKeys<T> = T extends unknown ? Extract<keyof T, string | number> : never;
|
|
1307
1140
|
type IndexValue<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? T[K] : never : never;
|
|
1308
1141
|
type MergeableFunction = (...args: never[]) => unknown;
|
|
@@ -1326,8 +1159,6 @@ type DeepMergeResult<T extends Record<string, unknown>[]> = [T[number]] extends
|
|
|
1326
1159
|
* // { a: { b: 1, d: 2 }, c: [1, 2] }
|
|
1327
1160
|
*/
|
|
1328
1161
|
export declare const deepMerge: <T extends Record<string, unknown>[]>(...objects: T) => DeepMergeResult<T>;
|
|
1329
|
-
//#endregion
|
|
1330
|
-
//#region src/utilities/getObjectEntries.d.ts
|
|
1331
1162
|
/**
|
|
1332
1163
|
* Returns the entries of an object with strongly typed keys and values.
|
|
1333
1164
|
*
|
|
@@ -1338,8 +1169,6 @@ export declare const deepMerge: <T extends Record<string, unknown>[]>(...objects
|
|
|
1338
1169
|
* getObjectEntries({ a: 1, b: 2 }); // [['a', 1], ['b', 2]]
|
|
1339
1170
|
*/
|
|
1340
1171
|
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
1172
|
/**
|
|
1344
1173
|
* Returns the keys of an object with strongly typed key type.
|
|
1345
1174
|
*
|
|
@@ -1350,8 +1179,6 @@ export declare const getObjectEntries: <T extends Record<string, unknown>>(obj:
|
|
|
1350
1179
|
* getObjectKeys({ a: 1, b: 2 }); // ['a', 'b']
|
|
1351
1180
|
*/
|
|
1352
1181
|
export declare const getObjectKeys: <T extends Record<string, unknown>>(obj: T) => (keyof T)[];
|
|
1353
|
-
//#endregion
|
|
1354
|
-
//#region src/utilities/getObjectValues.d.ts
|
|
1355
1182
|
/**
|
|
1356
1183
|
* Returns the values of an object with strongly typed value type.
|
|
1357
1184
|
*
|
|
@@ -1362,8 +1189,36 @@ export declare const getObjectKeys: <T extends Record<string, unknown>>(obj: T)
|
|
|
1362
1189
|
* getObjectValues({ a: 1, b: 2 }); // [1, 2]
|
|
1363
1190
|
*/
|
|
1364
1191
|
export declare const getObjectValues: <T extends Record<string, unknown>>(obj: T) => T[keyof T][];
|
|
1365
|
-
|
|
1366
|
-
|
|
1192
|
+
/**
|
|
1193
|
+
* Turns text into a whole number that is always the same for the same text.
|
|
1194
|
+
*
|
|
1195
|
+
* @param text - The text to hash.
|
|
1196
|
+
* @returns A whole number from 0 to 2,147,483,648.
|
|
1197
|
+
*
|
|
1198
|
+
* @remarks
|
|
1199
|
+
* Use it to pick a stable item from a list, for example an avatar color for a
|
|
1200
|
+
* name. The result is a whole number from 0 to 2,147,483,648, so for a list
|
|
1201
|
+
* that is not empty, `hashString(text) % list.length` is always a valid index.
|
|
1202
|
+
* An empty string gives 0.
|
|
1203
|
+
*
|
|
1204
|
+
* The result is the absolute value of Java's `String.hashCode`, with one
|
|
1205
|
+
* difference: it reads the text by Unicode code point. So a character above
|
|
1206
|
+
* U+FFFF, such as `'😀'`, counts once as its full value, where Java counts its
|
|
1207
|
+
* two UTF-16 halves. An emoji made of several code points, such as `'👍🏽'` or a
|
|
1208
|
+
* flag, counts once for each code point. A lone surrogate counts as its own
|
|
1209
|
+
* value.
|
|
1210
|
+
*
|
|
1211
|
+
* Spaces count like any other character, so `'Ada'` and `' Ada'` give
|
|
1212
|
+
* different numbers. It does not normalize the text, so `'é'` and `'e'` plus a
|
|
1213
|
+
* combining accent give different numbers. Different text can give the same
|
|
1214
|
+
* number, for example `'Aa'` and `'BB'`. Do not use it for security. The type requires a string: `null` or `undefined` throws a
|
|
1215
|
+
* `TypeError`.
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
* const colors = ['blue', 'green', 'pink'];
|
|
1219
|
+
* const color = colors[hashString('Ada Lovelace') % colors.length];
|
|
1220
|
+
*/
|
|
1221
|
+
export declare const hashString: (text: string) => number;
|
|
1367
1222
|
/**
|
|
1368
1223
|
* Loosely validates an email address string.
|
|
1369
1224
|
*
|
|
@@ -1375,8 +1230,6 @@ export declare const getObjectValues: <T extends Record<string, unknown>>(obj: T
|
|
|
1375
1230
|
* isEmail('user@example'); // false
|
|
1376
1231
|
*/
|
|
1377
1232
|
export declare const isEmail: (value: string) => boolean;
|
|
1378
|
-
//#endregion
|
|
1379
|
-
//#region src/utilities/isUrl.d.ts
|
|
1380
1233
|
/**
|
|
1381
1234
|
* Loosely validates a URL string.
|
|
1382
1235
|
*
|
|
@@ -1388,8 +1241,6 @@ export declare const isEmail: (value: string) => boolean;
|
|
|
1388
1241
|
* isUrl('not a url'); // false
|
|
1389
1242
|
*/
|
|
1390
1243
|
export declare const isUrl: (value: unknown) => boolean;
|
|
1391
|
-
//#endregion
|
|
1392
|
-
//#region src/utilities/mediaDurationString.d.ts
|
|
1393
1244
|
/**
|
|
1394
1245
|
* A string representation of a duration for a media. Assumes most medias
|
|
1395
1246
|
* are under an hour so only shows hours if media is over an hour.
|
|
@@ -1402,8 +1253,6 @@ export declare const isUrl: (value: unknown) => boolean;
|
|
|
1402
1253
|
* mediaDurationString(23423000); // '6:30:23'
|
|
1403
1254
|
*/
|
|
1404
1255
|
export declare const mediaDurationString: (numberOfMilliseconds: number) => string;
|
|
1405
|
-
//#endregion
|
|
1406
|
-
//#region src/utilities/millisecondsToDurationISOString.d.ts
|
|
1407
1256
|
/**
|
|
1408
1257
|
* Given a number of milliseconds, returns the ISO 8601 duration string
|
|
1409
1258
|
* rounded down from the number of seconds.
|
|
@@ -1416,8 +1265,6 @@ export declare const mediaDurationString: (numberOfMilliseconds: number) => stri
|
|
|
1416
1265
|
* millisecondsToDurationISOString(3605000); // 'PT1H5S'
|
|
1417
1266
|
*/
|
|
1418
1267
|
export declare const millisecondsToDurationISOString: (numberOfMilliseconds: number) => string;
|
|
1419
|
-
//#endregion
|
|
1420
|
-
//#region src/utilities/monthDayStringNumeric.d.ts
|
|
1421
1268
|
/**
|
|
1422
1269
|
* Converts a Date object into a month and day string formatted numerically,
|
|
1423
1270
|
* e.g. '06/03'. Formats with the en-US locale.
|
|
@@ -1431,8 +1278,6 @@ export declare const millisecondsToDurationISOString: (numberOfMilliseconds: num
|
|
|
1431
1278
|
* monthDayStringNumeric(new Date(2011, 11, 15)); // '12/15'
|
|
1432
1279
|
*/
|
|
1433
1280
|
export declare const monthDayStringNumeric: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
|
|
1434
|
-
//#endregion
|
|
1435
|
-
//#region src/utilities/noOpFnReturningFalse.d.ts
|
|
1436
1281
|
type NoOpFnReturningFalse = typeof noOpFnReturningFalse;
|
|
1437
1282
|
/**
|
|
1438
1283
|
* A function that does nothing and returns `false`. Useful as a default or
|
|
@@ -1444,8 +1289,6 @@ type NoOpFnReturningFalse = typeof noOpFnReturningFalse;
|
|
|
1444
1289
|
* noOpFnReturningFalse(); // false
|
|
1445
1290
|
*/
|
|
1446
1291
|
export declare const noOpFnReturningFalse: () => false;
|
|
1447
|
-
//#endregion
|
|
1448
|
-
//#region src/utilities/noOpFnReturningNull.d.ts
|
|
1449
1292
|
type NoOpFnReturningNull = typeof noOpFnReturningNull;
|
|
1450
1293
|
/**
|
|
1451
1294
|
* A function that does nothing and returns `null`. Useful as a default or
|
|
@@ -1457,8 +1300,6 @@ type NoOpFnReturningNull = typeof noOpFnReturningNull;
|
|
|
1457
1300
|
* noOpFnReturningNull(); // null
|
|
1458
1301
|
*/
|
|
1459
1302
|
export declare const noOpFnReturningNull: () => null;
|
|
1460
|
-
//#endregion
|
|
1461
|
-
//#region src/utilities/parseDateString.d.ts
|
|
1462
1303
|
/**
|
|
1463
1304
|
* Loosely parses a human-entered date string into a Date at local midnight.
|
|
1464
1305
|
* Accepts 'today' and 'tomorrow', month name prefixes (resolved to the next
|
|
@@ -1473,8 +1314,6 @@ export declare const noOpFnReturningNull: () => null;
|
|
|
1473
1314
|
* parseDateString('garbage'); // null
|
|
1474
1315
|
*/
|
|
1475
1316
|
export declare const parseDateString: (str: string) => Date | null;
|
|
1476
|
-
//#endregion
|
|
1477
|
-
//#region src/utilities/sessionDurationString.d.ts
|
|
1478
1317
|
/**
|
|
1479
1318
|
* A string representation of a duration for a user session. Assumes that
|
|
1480
1319
|
* sessions may or may not be more than an hour. To prevent confusion all
|
|
@@ -1487,8 +1326,6 @@ export declare const parseDateString: (str: string) => Date | null;
|
|
|
1487
1326
|
* sessionDurationString(2342300); // '0:39:02'
|
|
1488
1327
|
*/
|
|
1489
1328
|
export declare const sessionDurationString: (numberOfMilliseconds: number) => string;
|
|
1490
|
-
//#endregion
|
|
1491
|
-
//#region src/utilities/stripExtension.d.ts
|
|
1492
1329
|
/**
|
|
1493
1330
|
* Removes the file extension from a string.
|
|
1494
1331
|
*
|
|
@@ -1500,8 +1337,6 @@ export declare const sessionDurationString: (numberOfMilliseconds: number) => st
|
|
|
1500
1337
|
* stripExtension('example.test.ts'); // 'example.test'
|
|
1501
1338
|
*/
|
|
1502
1339
|
export declare const stripExtension: (str: string) => string;
|
|
1503
|
-
//#endregion
|
|
1504
|
-
//#region src/utilities/timeAgoString.d.ts
|
|
1505
1340
|
type TimeAgoOptions = {
|
|
1506
1341
|
nowAnchor?: Date;
|
|
1507
1342
|
includeTime?: boolean;
|
|
@@ -1525,8 +1360,6 @@ type TimeAgoOptions = {
|
|
|
1525
1360
|
* timeAgoString(new Date(Date.now() - 30_000)); // '< 1 minute ago'
|
|
1526
1361
|
*/
|
|
1527
1362
|
export declare const timeAgoString: (date: Date, { nowAnchor, includeTime }?: TimeAgoOptions) => string;
|
|
1528
|
-
//#endregion
|
|
1529
|
-
//#region src/utilities/timeOnlyString.d.ts
|
|
1530
1363
|
/**
|
|
1531
1364
|
* Converts a Date object into a time only string, e.g. '7:30 AM'.
|
|
1532
1365
|
* Formats with the en-US locale.
|
|
@@ -1540,8 +1373,6 @@ export declare const timeAgoString: (date: Date, { nowAnchor, includeTime }?: Ti
|
|
|
1540
1373
|
* timeOnlyString(new Date(2011, 11, 15, 7, 30)); // '7:30 AM'
|
|
1541
1374
|
*/
|
|
1542
1375
|
export declare const timeOnlyString: (date: unknown, { timeZone }?: DateOnlyStringOptions) => string;
|
|
1543
|
-
//#endregion
|
|
1544
|
-
//#region src/utilities/truncateString.d.ts
|
|
1545
1376
|
type TruncateStringOptions = {
|
|
1546
1377
|
/**
|
|
1547
1378
|
* The string that ends a truncated result. It counts toward `maxLength`.
|
|
@@ -1568,8 +1399,6 @@ type TruncateStringOptions = {
|
|
|
1568
1399
|
* truncateString('The quick brown fox', 9, { ellipsis: '' }); // 'The quick'
|
|
1569
1400
|
*/
|
|
1570
1401
|
export declare const truncateString: (text: string, maxLength: number, { ellipsis }?: TruncateStringOptions) => string;
|
|
1571
|
-
//#endregion
|
|
1572
|
-
//#region src/utilities/tupleIncludes.d.ts
|
|
1573
1402
|
/**
|
|
1574
1403
|
* Checks if a tuple includes the given item, with type narrowing.
|
|
1575
1404
|
*
|
|
@@ -1583,6 +1412,21 @@ export declare const truncateString: (text: string, maxLength: number, { ellipsi
|
|
|
1583
1412
|
* tupleIncludes(tuple, 'z'); // false
|
|
1584
1413
|
*/
|
|
1585
1414
|
export declare const tupleIncludes: <TTuple extends readonly TItem[], TItem>(tuple: TTuple, item: TItem) => item is TTuple[number];
|
|
1586
|
-
|
|
1415
|
+
/**
|
|
1416
|
+
* Waits for about the given number of milliseconds.
|
|
1417
|
+
* It always starts a `setTimeout` timer, even for 0. So `await wait(0)` lets
|
|
1418
|
+
* queued promise callbacks run before it continues. It makes no promise about
|
|
1419
|
+
* the order of other timers or events. Node can resolve up to 1 ms early.
|
|
1420
|
+
* Browsers can resolve later than asked, for example in a background tab. The
|
|
1421
|
+
* wait cannot be cancelled, and in Node the pending timer keeps the process
|
|
1422
|
+
* running.
|
|
1423
|
+
*
|
|
1424
|
+
* @param milliseconds - How long to wait. A fraction is rounded down. Zero, a negative value, or NaN waits for a timer with a delay of 0. A value above 2,147,483,647 (about 24.8 days), including Infinity, waits 2,147,483,647 ms.
|
|
1425
|
+
* @returns A promise that resolves to `undefined` after the delay.
|
|
1426
|
+
*
|
|
1427
|
+
* @example
|
|
1428
|
+
* await wait(500); // continues after about half a second
|
|
1429
|
+
*/
|
|
1430
|
+
export declare const wait: (milliseconds: number) => Promise<void>;
|
|
1587
1431
|
export type { Arrayable, AsyncNoOpFn, AsyncOrSyncNoOpFn, DateOnlyStringOptions, DateTimeRoundedOverload, DeepMerged, Falsy, NestedNonNullable, Nil, Nilable, NilableArray, NoOpFn, NoOpFnReturningFalse, NoOpFnReturningNull, NonEmptyArray, NotNilable, Nullable, NullableProperties, TimeAgoOptions, TimeDuration, TruncateStringOptions, Truthy, Undefinable, WistiaDateTimeObject };
|
|
1588
1432
|
//# sourceMappingURL=index.d.mts.map
|