@xylabs/object 5.0.84 → 5.0.86
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/README.md +508 -838
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
## Reference
|
|
19
21
|
|
|
20
22
|
**@xylabs/object**
|
|
@@ -23,9 +25,11 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
23
25
|
|
|
24
26
|
## Modules
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
| Module | Description |
|
|
29
|
+
| ------ | ------ |
|
|
30
|
+
| [index-deprecated](#index-deprecated/README) | - |
|
|
31
|
+
| [index-un-deprecated](#index-un-deprecated/README) | - |
|
|
32
|
+
| [index](#index/README) | - |
|
|
29
33
|
|
|
30
34
|
### index
|
|
31
35
|
|
|
@@ -43,9 +47,9 @@ Factory class for creating type-guard functions that validate objects against a
|
|
|
43
47
|
|
|
44
48
|
## Type Parameters
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`T` *extends* `TypedObject`
|
|
50
|
+
| Type Parameter |
|
|
51
|
+
| ------ |
|
|
52
|
+
| `T` *extends* `TypedObject` |
|
|
49
53
|
|
|
50
54
|
## Constructors
|
|
51
55
|
|
|
@@ -64,24 +68,17 @@ new IsObjectFactory<T>(): IsObjectFactory<T>;
|
|
|
64
68
|
### create()
|
|
65
69
|
|
|
66
70
|
```ts
|
|
67
|
-
create(shape
|
|
71
|
+
create(shape?: ObjectTypeShape, additionalChecks?: TypeCheck<TypedObject>[]): TypeCheck<T>;
|
|
68
72
|
```
|
|
69
73
|
|
|
70
74
|
Creates a type-guard function that validates an object matches the given shape and passes additional checks.
|
|
71
75
|
|
|
72
76
|
### Parameters
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
`ObjectTypeShape`
|
|
77
|
-
|
|
78
|
-
An optional map of property names to expected types.
|
|
79
|
-
|
|
80
|
-
#### additionalChecks?
|
|
81
|
-
|
|
82
|
-
[`TypeCheck`](#../type-aliases/TypeCheck)\<`TypedObject`\>[]
|
|
83
|
-
|
|
84
|
-
Optional extra type-check functions to run after shape validation.
|
|
78
|
+
| Parameter | Type | Description |
|
|
79
|
+
| ------ | ------ | ------ |
|
|
80
|
+
| `shape?` | `ObjectTypeShape` | An optional map of property names to expected types. |
|
|
81
|
+
| `additionalChecks?` | [`TypeCheck`](#../type-aliases/TypeCheck)\<`TypedObject`\>[] | Optional extra type-check functions to run after shape validation. |
|
|
85
82
|
|
|
86
83
|
### Returns
|
|
87
84
|
|
|
@@ -103,23 +100,23 @@ Abstract base class that wraps an object and provides typed access to it.
|
|
|
103
100
|
|
|
104
101
|
## Type Parameters
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
`T` *extends* [`EmptyObject`](#../type-aliases/EmptyObject)
|
|
103
|
+
| Type Parameter | Default type |
|
|
104
|
+
| ------ | ------ |
|
|
105
|
+
| `T` *extends* [`EmptyObject`](#../type-aliases/EmptyObject) | [`EmptyObject`](#../type-aliases/EmptyObject) |
|
|
109
106
|
|
|
110
107
|
## Constructors
|
|
111
108
|
|
|
112
109
|
### Constructor
|
|
113
110
|
|
|
114
111
|
```ts
|
|
115
|
-
new ObjectWrapper<T>(obj): ObjectWrapper<T>;
|
|
112
|
+
new ObjectWrapper<T>(obj: T): ObjectWrapper<T>;
|
|
116
113
|
```
|
|
117
114
|
|
|
118
115
|
### Parameters
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
`T`
|
|
117
|
+
| Parameter | Type |
|
|
118
|
+
| ------ | ------ |
|
|
119
|
+
| `obj` | `T` |
|
|
123
120
|
|
|
124
121
|
### Returns
|
|
125
122
|
|
|
@@ -127,11 +124,9 @@ new ObjectWrapper<T>(obj): ObjectWrapper<T>;
|
|
|
127
124
|
|
|
128
125
|
## Properties
|
|
129
126
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
readonly obj: T;
|
|
134
|
-
```
|
|
127
|
+
| Property | Modifier | Type |
|
|
128
|
+
| ------ | ------ | ------ |
|
|
129
|
+
| <a id="obj"></a> `obj` | `readonly` | `T` |
|
|
135
130
|
|
|
136
131
|
## Accessors
|
|
137
132
|
|
|
@@ -161,9 +156,9 @@ Abstract base class for validators that wraps a partial object and provides a va
|
|
|
161
156
|
|
|
162
157
|
## Type Parameters
|
|
163
158
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
`T` *extends* [`EmptyObject`](#../type-aliases/EmptyObject)
|
|
159
|
+
| Type Parameter | Default type |
|
|
160
|
+
| ------ | ------ |
|
|
161
|
+
| `T` *extends* [`EmptyObject`](#../type-aliases/EmptyObject) | [`AnyObject`](#../type-aliases/AnyObject) |
|
|
167
162
|
|
|
168
163
|
## Implements
|
|
169
164
|
|
|
@@ -174,14 +169,14 @@ Abstract base class for validators that wraps a partial object and provides a va
|
|
|
174
169
|
### Constructor
|
|
175
170
|
|
|
176
171
|
```ts
|
|
177
|
-
new ValidatorBase<T>(obj): ValidatorBase<T>;
|
|
172
|
+
new ValidatorBase<T>(obj: T): ValidatorBase<T>;
|
|
178
173
|
```
|
|
179
174
|
|
|
180
175
|
### Parameters
|
|
181
176
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
`T`
|
|
177
|
+
| Parameter | Type |
|
|
178
|
+
| ------ | ------ |
|
|
179
|
+
| `obj` | `T` |
|
|
185
180
|
|
|
186
181
|
### Returns
|
|
187
182
|
|
|
@@ -193,15 +188,9 @@ new ValidatorBase<T>(obj): ValidatorBase<T>;
|
|
|
193
188
|
|
|
194
189
|
## Properties
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
readonly obj: T;
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Inherited from
|
|
203
|
-
|
|
204
|
-
[`ObjectWrapper`](#ObjectWrapper).[`obj`](ObjectWrapper.md#obj)
|
|
191
|
+
| Property | Modifier | Type | Inherited from |
|
|
192
|
+
| ------ | ------ | ------ | ------ |
|
|
193
|
+
| <a id="obj"></a> `obj` | `readonly` | `T` | [`ObjectWrapper`](#ObjectWrapper).[`obj`](ObjectWrapper.md#obj) |
|
|
205
194
|
|
|
206
195
|
## Accessors
|
|
207
196
|
|
|
@@ -226,14 +215,14 @@ get protected stringKeyObj(): StringKeyObject;
|
|
|
226
215
|
### validate()
|
|
227
216
|
|
|
228
217
|
```ts
|
|
229
|
-
abstract validate(payload): Promisable<Error[]>;
|
|
218
|
+
abstract validate(payload: T): Promisable<Error[]>;
|
|
230
219
|
```
|
|
231
220
|
|
|
232
221
|
### Parameters
|
|
233
222
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
`T`
|
|
223
|
+
| Parameter | Type |
|
|
224
|
+
| ------ | ------ |
|
|
225
|
+
| `payload` | `T` |
|
|
237
226
|
|
|
238
227
|
### Returns
|
|
239
228
|
|
|
@@ -252,38 +241,36 @@ abstract validate(payload): Promisable<Error[]>;
|
|
|
252
241
|
***
|
|
253
242
|
|
|
254
243
|
```ts
|
|
255
|
-
function createDeepMerge(options): <T>(...objects) => MergeAll<T>;
|
|
244
|
+
function createDeepMerge(options: MergeOptions): <T>(...objects: T) => MergeAll<T>;
|
|
256
245
|
```
|
|
257
246
|
|
|
258
247
|
Creates a deep merge function with the specified options.
|
|
259
248
|
|
|
260
249
|
## Parameters
|
|
261
250
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
`MergeOptions`
|
|
265
|
-
|
|
266
|
-
Options for merging.
|
|
251
|
+
| Parameter | Type | Description |
|
|
252
|
+
| ------ | ------ | ------ |
|
|
253
|
+
| `options` | `MergeOptions` | Options for merging. |
|
|
267
254
|
|
|
268
255
|
## Returns
|
|
269
256
|
|
|
270
257
|
A deep merge function configured for the specified options.
|
|
271
258
|
|
|
272
259
|
```ts
|
|
273
|
-
<T>(...objects): MergeAll<T>;
|
|
260
|
+
<T>(...objects: T): MergeAll<T>;
|
|
274
261
|
```
|
|
275
262
|
|
|
276
263
|
### Type Parameters
|
|
277
264
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
`T` *extends* [`AnyObject`](#../type-aliases/AnyObject)[]
|
|
265
|
+
| Type Parameter |
|
|
266
|
+
| ------ |
|
|
267
|
+
| `T` *extends* [`AnyObject`](#../type-aliases/AnyObject)[] |
|
|
281
268
|
|
|
282
269
|
### Parameters
|
|
283
270
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
...`T`
|
|
271
|
+
| Parameter | Type |
|
|
272
|
+
| ------ | ------ |
|
|
273
|
+
| ...`objects` | `T` |
|
|
287
274
|
|
|
288
275
|
### Returns
|
|
289
276
|
|
|
@@ -298,16 +285,16 @@ A deep merge function configured for the specified options.
|
|
|
298
285
|
## Call Signature
|
|
299
286
|
|
|
300
287
|
```ts
|
|
301
|
-
function isObject(value): value is object;
|
|
288
|
+
function isObject(value: unknown): value is object;
|
|
302
289
|
```
|
|
303
290
|
|
|
304
291
|
Type guard that checks whether a value is a plain object (not null and not an array).
|
|
305
292
|
|
|
306
293
|
### Parameters
|
|
307
294
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
`unknown`
|
|
295
|
+
| Parameter | Type |
|
|
296
|
+
| ------ | ------ |
|
|
297
|
+
| `value` | `unknown` |
|
|
311
298
|
|
|
312
299
|
### Returns
|
|
313
300
|
|
|
@@ -316,22 +303,22 @@ Type guard that checks whether a value is a plain object (not null and not an ar
|
|
|
316
303
|
## Call Signature
|
|
317
304
|
|
|
318
305
|
```ts
|
|
319
|
-
function isObject<T>(value): value is Extract<T, object>;
|
|
306
|
+
function isObject<T>(value: T): value is Extract<T, object>;
|
|
320
307
|
```
|
|
321
308
|
|
|
322
309
|
Type guard that checks whether a value is a plain object (not null and not an array).
|
|
323
310
|
|
|
324
311
|
### Type Parameters
|
|
325
312
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
`T` *extends* `object`
|
|
313
|
+
| Type Parameter |
|
|
314
|
+
| ------ |
|
|
315
|
+
| `T` *extends* `object` |
|
|
329
316
|
|
|
330
317
|
### Parameters
|
|
331
318
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
`T`
|
|
319
|
+
| Parameter | Type |
|
|
320
|
+
| ------ | ------ |
|
|
321
|
+
| `value` | `T` |
|
|
335
322
|
|
|
336
323
|
### Returns
|
|
337
324
|
|
|
@@ -344,18 +331,15 @@ Type guard that checks whether a value is a plain object (not null and not an ar
|
|
|
344
331
|
***
|
|
345
332
|
|
|
346
333
|
```ts
|
|
347
|
-
function isType(value, expectedType): boolean;
|
|
334
|
+
function isType(value: unknown, expectedType: FieldType): boolean;
|
|
348
335
|
```
|
|
349
336
|
|
|
350
337
|
## Parameters
|
|
351
338
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
`unknown`
|
|
355
|
-
|
|
356
|
-
### expectedType
|
|
357
|
-
|
|
358
|
-
`FieldType`
|
|
339
|
+
| Parameter | Type |
|
|
340
|
+
| ------ | ------ |
|
|
341
|
+
| `value` | `unknown` |
|
|
342
|
+
| `expectedType` | `FieldType` |
|
|
359
343
|
|
|
360
344
|
## Returns
|
|
361
345
|
|
|
@@ -373,38 +357,26 @@ use from @xylabs/typeof instead
|
|
|
373
357
|
|
|
374
358
|
```ts
|
|
375
359
|
function omitBy<T>(
|
|
376
|
-
obj,
|
|
377
|
-
predicate,
|
|
378
|
-
maxDepth
|
|
360
|
+
obj: T,
|
|
361
|
+
predicate: OmitByPredicate,
|
|
362
|
+
maxDepth?: number): Partial<T>;
|
|
379
363
|
```
|
|
380
364
|
|
|
381
365
|
Creates a new object excluding properties that satisfy the predicate, with optional recursive depth.
|
|
382
366
|
|
|
383
367
|
## Type Parameters
|
|
384
368
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
`T` *extends* `object`
|
|
369
|
+
| Type Parameter |
|
|
370
|
+
| ------ |
|
|
371
|
+
| `T` *extends* `object` |
|
|
388
372
|
|
|
389
373
|
## Parameters
|
|
390
374
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
`T`
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
### predicate
|
|
398
|
-
|
|
399
|
-
[`OmitByPredicate`](#../type-aliases/OmitByPredicate)
|
|
400
|
-
|
|
401
|
-
A function that returns true for properties to exclude.
|
|
402
|
-
|
|
403
|
-
### maxDepth?
|
|
404
|
-
|
|
405
|
-
`number` = `1`
|
|
406
|
-
|
|
407
|
-
Maximum recursion depth for nested objects.
|
|
375
|
+
| Parameter | Type | Default value | Description |
|
|
376
|
+
| ------ | ------ | ------ | ------ |
|
|
377
|
+
| `obj` | `T` | `undefined` | The source object to omit properties from. |
|
|
378
|
+
| `predicate` | [`OmitByPredicate`](#../type-aliases/OmitByPredicate) | `undefined` | A function that returns true for properties to exclude. |
|
|
379
|
+
| `maxDepth` | `number` | `1` | Maximum recursion depth for nested objects. |
|
|
408
380
|
|
|
409
381
|
## Returns
|
|
410
382
|
|
|
@@ -420,42 +392,27 @@ A partial copy of the object without matching properties.
|
|
|
420
392
|
|
|
421
393
|
```ts
|
|
422
394
|
function omitByPrefix<T, P>(
|
|
423
|
-
payload,
|
|
424
|
-
prefix,
|
|
425
|
-
maxDepth
|
|
395
|
+
payload: T,
|
|
396
|
+
prefix: P,
|
|
397
|
+
maxDepth?: number): DeepOmitStartsWith<T, P>;
|
|
426
398
|
```
|
|
427
399
|
|
|
428
400
|
Omits all properties whose keys start with the given prefix, recursively through nested objects.
|
|
429
401
|
|
|
430
402
|
## Type Parameters
|
|
431
403
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
`T` *extends* `object`
|
|
435
|
-
|
|
436
|
-
### P
|
|
437
|
-
|
|
438
|
-
`P` *extends* `string`
|
|
404
|
+
| Type Parameter |
|
|
405
|
+
| ------ |
|
|
406
|
+
| `T` *extends* `object` |
|
|
407
|
+
| `P` *extends* `string` |
|
|
439
408
|
|
|
440
409
|
## Parameters
|
|
441
410
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
`T`
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
### prefix
|
|
449
|
-
|
|
450
|
-
`P`
|
|
451
|
-
|
|
452
|
-
The string prefix to match keys against.
|
|
453
|
-
|
|
454
|
-
### maxDepth?
|
|
455
|
-
|
|
456
|
-
`number` = `100`
|
|
457
|
-
|
|
458
|
-
Maximum recursion depth.
|
|
411
|
+
| Parameter | Type | Default value | Description |
|
|
412
|
+
| ------ | ------ | ------ | ------ |
|
|
413
|
+
| `payload` | `T` | `undefined` | The source object. |
|
|
414
|
+
| `prefix` | `P` | `undefined` | The string prefix to match keys against. |
|
|
415
|
+
| `maxDepth` | `number` | `100` | Maximum recursion depth. |
|
|
459
416
|
|
|
460
417
|
## Returns
|
|
461
418
|
|
|
@@ -471,38 +428,26 @@ A new object without properties that have matching prefixed keys.
|
|
|
471
428
|
|
|
472
429
|
```ts
|
|
473
430
|
function pickBy<T>(
|
|
474
|
-
obj,
|
|
475
|
-
predicate,
|
|
476
|
-
maxDepth
|
|
431
|
+
obj: T,
|
|
432
|
+
predicate: PickByPredicate,
|
|
433
|
+
maxDepth?: number): Partial<T>;
|
|
477
434
|
```
|
|
478
435
|
|
|
479
436
|
Creates a new object containing only the properties that satisfy the predicate, with optional recursive depth.
|
|
480
437
|
|
|
481
438
|
## Type Parameters
|
|
482
439
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
`T` *extends* `object`
|
|
440
|
+
| Type Parameter |
|
|
441
|
+
| ------ |
|
|
442
|
+
| `T` *extends* `object` |
|
|
486
443
|
|
|
487
444
|
## Parameters
|
|
488
445
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
`T`
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
### predicate
|
|
496
|
-
|
|
497
|
-
[`PickByPredicate`](#../type-aliases/PickByPredicate)
|
|
498
|
-
|
|
499
|
-
A function that returns true for properties to include.
|
|
500
|
-
|
|
501
|
-
### maxDepth?
|
|
502
|
-
|
|
503
|
-
`number` = `1`
|
|
504
|
-
|
|
505
|
-
Maximum recursion depth for nested objects.
|
|
446
|
+
| Parameter | Type | Default value | Description |
|
|
447
|
+
| ------ | ------ | ------ | ------ |
|
|
448
|
+
| `obj` | `T` | `undefined` | The source object to pick properties from. |
|
|
449
|
+
| `predicate` | [`PickByPredicate`](#../type-aliases/PickByPredicate) | `undefined` | A function that returns true for properties to include. |
|
|
450
|
+
| `maxDepth` | `number` | `1` | Maximum recursion depth for nested objects. |
|
|
506
451
|
|
|
507
452
|
## Returns
|
|
508
453
|
|
|
@@ -518,42 +463,27 @@ A partial copy of the object with only matching properties.
|
|
|
518
463
|
|
|
519
464
|
```ts
|
|
520
465
|
function pickByPrefix<T, P>(
|
|
521
|
-
payload,
|
|
522
|
-
prefix,
|
|
523
|
-
maxDepth
|
|
466
|
+
payload: T,
|
|
467
|
+
prefix: P,
|
|
468
|
+
maxDepth?: number): DeepPickStartsWith<T, P>;
|
|
524
469
|
```
|
|
525
470
|
|
|
526
471
|
Picks all properties whose keys start with the given prefix, recursively through nested objects.
|
|
527
472
|
|
|
528
473
|
## Type Parameters
|
|
529
474
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
`T` *extends* `object`
|
|
533
|
-
|
|
534
|
-
### P
|
|
535
|
-
|
|
536
|
-
`P` *extends* `string`
|
|
475
|
+
| Type Parameter |
|
|
476
|
+
| ------ |
|
|
477
|
+
| `T` *extends* `object` |
|
|
478
|
+
| `P` *extends* `string` |
|
|
537
479
|
|
|
538
480
|
## Parameters
|
|
539
481
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
`T`
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
### prefix
|
|
547
|
-
|
|
548
|
-
`P`
|
|
549
|
-
|
|
550
|
-
The string prefix to match keys against.
|
|
551
|
-
|
|
552
|
-
### maxDepth?
|
|
553
|
-
|
|
554
|
-
`number` = `100`
|
|
555
|
-
|
|
556
|
-
Maximum recursion depth.
|
|
482
|
+
| Parameter | Type | Default value | Description |
|
|
483
|
+
| ------ | ------ | ------ | ------ |
|
|
484
|
+
| `payload` | `T` | `undefined` | The source object. |
|
|
485
|
+
| `prefix` | `P` | `undefined` | The string prefix to match keys against. |
|
|
486
|
+
| `maxDepth` | `number` | `100` | Maximum recursion depth. |
|
|
557
487
|
|
|
558
488
|
## Returns
|
|
559
489
|
|
|
@@ -568,34 +498,24 @@ A new object containing only properties with matching prefixed keys.
|
|
|
568
498
|
***
|
|
569
499
|
|
|
570
500
|
```ts
|
|
571
|
-
function removeFields<T, K>(obj, fields): Omit<T, K>;
|
|
501
|
+
function removeFields<T, K>(obj: T, fields: K[]): Omit<T, K>;
|
|
572
502
|
```
|
|
573
503
|
|
|
574
504
|
Returns a shallow copy of the object with the specified fields removed.
|
|
575
505
|
|
|
576
506
|
## Type Parameters
|
|
577
507
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
`T` *extends* `object`
|
|
581
|
-
|
|
582
|
-
### K
|
|
583
|
-
|
|
584
|
-
`K` *extends* `string` \| `number` \| `symbol`
|
|
508
|
+
| Type Parameter |
|
|
509
|
+
| ------ |
|
|
510
|
+
| `T` *extends* `object` |
|
|
511
|
+
| `K` *extends* `string` \| `number` \| `symbol` |
|
|
585
512
|
|
|
586
513
|
## Parameters
|
|
587
514
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
`T`
|
|
591
|
-
|
|
592
|
-
The source object.
|
|
593
|
-
|
|
594
|
-
### fields
|
|
595
|
-
|
|
596
|
-
`K`[]
|
|
597
|
-
|
|
598
|
-
An array of keys to remove.
|
|
515
|
+
| Parameter | Type | Description |
|
|
516
|
+
| ------ | ------ | ------ |
|
|
517
|
+
| `obj` | `T` | The source object. |
|
|
518
|
+
| `fields` | `K`[] | An array of keys to remove. |
|
|
599
519
|
|
|
600
520
|
## Returns
|
|
601
521
|
|
|
@@ -610,24 +530,17 @@ A new object without the specified fields.
|
|
|
610
530
|
***
|
|
611
531
|
|
|
612
532
|
```ts
|
|
613
|
-
function toSafeJson(value, maxDepth
|
|
533
|
+
function toSafeJson(value: unknown, maxDepth?: number): unknown;
|
|
614
534
|
```
|
|
615
535
|
|
|
616
536
|
Converts a value to a JSON-safe representation, handling circular references and non-serializable types.
|
|
617
537
|
|
|
618
538
|
## Parameters
|
|
619
539
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
`unknown`
|
|
623
|
-
|
|
624
|
-
The value to convert.
|
|
625
|
-
|
|
626
|
-
### maxDepth?
|
|
627
|
-
|
|
628
|
-
`number` = `3`
|
|
629
|
-
|
|
630
|
-
Maximum recursion depth.
|
|
540
|
+
| Parameter | Type | Default value | Description |
|
|
541
|
+
| ------ | ------ | ------ | ------ |
|
|
542
|
+
| `value` | `unknown` | `undefined` | The value to convert. |
|
|
543
|
+
| `maxDepth` | `number` | `3` | Maximum recursion depth. |
|
|
631
544
|
|
|
632
545
|
## Returns
|
|
633
546
|
|
|
@@ -643,32 +556,20 @@ A JSON-safe value.
|
|
|
643
556
|
|
|
644
557
|
```ts
|
|
645
558
|
function toSafeJsonArray(
|
|
646
|
-
value,
|
|
647
|
-
cycleList
|
|
648
|
-
maxDepth
|
|
559
|
+
value: unknown[],
|
|
560
|
+
cycleList?: unknown[],
|
|
561
|
+
maxDepth?: number): unknown[];
|
|
649
562
|
```
|
|
650
563
|
|
|
651
564
|
Converts an array to a JSON-safe array, handling circular references and depth limits.
|
|
652
565
|
|
|
653
566
|
## Parameters
|
|
654
567
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
`unknown`[]
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
### cycleList?
|
|
662
|
-
|
|
663
|
-
`unknown`[]
|
|
664
|
-
|
|
665
|
-
Tracks visited objects to detect circular references.
|
|
666
|
-
|
|
667
|
-
### maxDepth?
|
|
668
|
-
|
|
669
|
-
`number` = `3`
|
|
670
|
-
|
|
671
|
-
Maximum recursion depth before truncating.
|
|
568
|
+
| Parameter | Type | Default value | Description |
|
|
569
|
+
| ------ | ------ | ------ | ------ |
|
|
570
|
+
| `value` | `unknown`[] | `undefined` | The array to convert. |
|
|
571
|
+
| `cycleList?` | `unknown`[] | `undefined` | Tracks visited objects to detect circular references. |
|
|
572
|
+
| `maxDepth?` | `number` | `3` | Maximum recursion depth before truncating. |
|
|
672
573
|
|
|
673
574
|
## Returns
|
|
674
575
|
|
|
@@ -684,32 +585,20 @@ A JSON-safe array representation.
|
|
|
684
585
|
|
|
685
586
|
```ts
|
|
686
587
|
function toSafeJsonObject(
|
|
687
|
-
value,
|
|
688
|
-
cycleList
|
|
689
|
-
maxDepth
|
|
588
|
+
value: object,
|
|
589
|
+
cycleList?: unknown[],
|
|
590
|
+
maxDepth?: number): JsonObject;
|
|
690
591
|
```
|
|
691
592
|
|
|
692
593
|
Converts an object to a JSON-safe object, handling circular references and depth limits.
|
|
693
594
|
|
|
694
595
|
## Parameters
|
|
695
596
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
`object`
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
### cycleList?
|
|
703
|
-
|
|
704
|
-
`unknown`[]
|
|
705
|
-
|
|
706
|
-
Tracks visited objects to detect circular references.
|
|
707
|
-
|
|
708
|
-
### maxDepth?
|
|
709
|
-
|
|
710
|
-
`number` = `3`
|
|
711
|
-
|
|
712
|
-
Maximum recursion depth before truncating.
|
|
597
|
+
| Parameter | Type | Default value | Description |
|
|
598
|
+
| ------ | ------ | ------ | ------ |
|
|
599
|
+
| `value` | `object` | `undefined` | The object to convert. |
|
|
600
|
+
| `cycleList?` | `unknown`[] | `undefined` | Tracks visited objects to detect circular references. |
|
|
601
|
+
| `maxDepth?` | `number` | `3` | Maximum recursion depth before truncating. |
|
|
713
602
|
|
|
714
603
|
## Returns
|
|
715
604
|
|
|
@@ -724,24 +613,17 @@ A JSON-safe object representation.
|
|
|
724
613
|
***
|
|
725
614
|
|
|
726
615
|
```ts
|
|
727
|
-
function toSafeJsonString(value, maxDepth
|
|
616
|
+
function toSafeJsonString(value: unknown, maxDepth?: number): string;
|
|
728
617
|
```
|
|
729
618
|
|
|
730
619
|
Converts a value to a pretty-printed JSON string, safely handling circular references and non-JSON types.
|
|
731
620
|
|
|
732
621
|
## Parameters
|
|
733
622
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
`unknown`
|
|
737
|
-
|
|
738
|
-
The value to serialize.
|
|
739
|
-
|
|
740
|
-
### maxDepth?
|
|
741
|
-
|
|
742
|
-
`number` = `3`
|
|
743
|
-
|
|
744
|
-
Maximum recursion depth.
|
|
623
|
+
| Parameter | Type | Default value | Description |
|
|
624
|
+
| ------ | ------ | ------ | ------ |
|
|
625
|
+
| `value` | `unknown` | `undefined` | The value to serialize. |
|
|
626
|
+
| `maxDepth` | `number` | `3` | Maximum recursion depth. |
|
|
745
627
|
|
|
746
628
|
## Returns
|
|
747
629
|
|
|
@@ -757,9 +639,9 @@ A formatted JSON string.
|
|
|
757
639
|
|
|
758
640
|
```ts
|
|
759
641
|
function toSafeJsonValue(
|
|
760
|
-
value,
|
|
761
|
-
cycleList
|
|
762
|
-
maxDepth
|
|
642
|
+
value: unknown,
|
|
643
|
+
cycleList?: unknown[],
|
|
644
|
+
maxDepth?: number): unknown;
|
|
763
645
|
```
|
|
764
646
|
|
|
765
647
|
Converts an unknown value to a JSON-safe value, replacing circular references with '[Circular]' and
|
|
@@ -767,23 +649,11 @@ non-JSON types with descriptive placeholder strings.
|
|
|
767
649
|
|
|
768
650
|
## Parameters
|
|
769
651
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
`unknown`
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
### cycleList?
|
|
777
|
-
|
|
778
|
-
`unknown`[]
|
|
779
|
-
|
|
780
|
-
Tracks visited objects to detect circular references.
|
|
781
|
-
|
|
782
|
-
### maxDepth?
|
|
783
|
-
|
|
784
|
-
`number` = `3`
|
|
785
|
-
|
|
786
|
-
Maximum recursion depth before truncating with '[MaxDepth]'.
|
|
652
|
+
| Parameter | Type | Default value | Description |
|
|
653
|
+
| ------ | ------ | ------ | ------ |
|
|
654
|
+
| `value` | `unknown` | `undefined` | The value to convert. |
|
|
655
|
+
| `cycleList?` | `unknown`[] | `undefined` | Tracks visited objects to detect circular references. |
|
|
656
|
+
| `maxDepth?` | `number` | `3` | Maximum recursion depth before truncating with '[MaxDepth]'. |
|
|
787
657
|
|
|
788
658
|
## Returns
|
|
789
659
|
|
|
@@ -807,15 +677,9 @@ Configuration options for object type checking.
|
|
|
807
677
|
|
|
808
678
|
## Properties
|
|
809
679
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
optional log: boolean | Logger;
|
|
814
|
-
```
|
|
815
|
-
|
|
816
|
-
### Inherited from
|
|
817
|
-
|
|
818
|
-
[`TypeCheckConfig`](#TypeCheckConfig).[`log`](TypeCheckConfig.md#log)
|
|
680
|
+
| Property | Type | Inherited from |
|
|
681
|
+
| ------ | ------ | ------ |
|
|
682
|
+
| <a id="log"></a> `log?` | `boolean` \| `Logger` | [`TypeCheckConfig`](#TypeCheckConfig).[`log`](TypeCheckConfig.md#log) |
|
|
819
683
|
|
|
820
684
|
### <a id="TypeCheckConfig"></a>TypeCheckConfig
|
|
821
685
|
|
|
@@ -833,11 +697,9 @@ Configuration options for type check functions, with optional logging.
|
|
|
833
697
|
|
|
834
698
|
## Properties
|
|
835
699
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
optional log: boolean | Logger;
|
|
840
|
-
```
|
|
700
|
+
| Property | Type |
|
|
701
|
+
| ------ | ------ |
|
|
702
|
+
| <a id="log"></a> `log?` | `boolean` \| `Logger` |
|
|
841
703
|
|
|
842
704
|
### <a id="TypeCheckOptionalConfig"></a>TypeCheckOptionalConfig
|
|
843
705
|
|
|
@@ -853,23 +715,10 @@ Type check configuration that marks the value as optional, returning undefined o
|
|
|
853
715
|
|
|
854
716
|
## Properties
|
|
855
717
|
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
```
|
|
861
|
-
|
|
862
|
-
### Inherited from
|
|
863
|
-
|
|
864
|
-
[`TypeCheckConfig`](#TypeCheckConfig).[`log`](TypeCheckConfig.md#log)
|
|
865
|
-
|
|
866
|
-
***
|
|
867
|
-
|
|
868
|
-
### required
|
|
869
|
-
|
|
870
|
-
```ts
|
|
871
|
-
required: false;
|
|
872
|
-
```
|
|
718
|
+
| Property | Type | Inherited from |
|
|
719
|
+
| ------ | ------ | ------ |
|
|
720
|
+
| <a id="log"></a> `log?` | `boolean` \| `Logger` | [`TypeCheckConfig`](#TypeCheckConfig).[`log`](TypeCheckConfig.md#log) |
|
|
721
|
+
| <a id="required"></a> `required` | `false` | - |
|
|
873
722
|
|
|
874
723
|
### <a id="TypeCheckRequiredConfig"></a>TypeCheckRequiredConfig
|
|
875
724
|
|
|
@@ -885,23 +734,10 @@ Type check configuration that marks the value as required, causing assertions on
|
|
|
885
734
|
|
|
886
735
|
## Properties
|
|
887
736
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
```
|
|
893
|
-
|
|
894
|
-
### Inherited from
|
|
895
|
-
|
|
896
|
-
[`TypeCheckConfig`](#TypeCheckConfig).[`log`](TypeCheckConfig.md#log)
|
|
897
|
-
|
|
898
|
-
***
|
|
899
|
-
|
|
900
|
-
### required
|
|
901
|
-
|
|
902
|
-
```ts
|
|
903
|
-
required: true;
|
|
904
|
-
```
|
|
737
|
+
| Property | Type | Inherited from |
|
|
738
|
+
| ------ | ------ | ------ |
|
|
739
|
+
| <a id="log"></a> `log?` | `boolean` \| `Logger` | [`TypeCheckConfig`](#TypeCheckConfig).[`log`](TypeCheckConfig.md#log) |
|
|
740
|
+
| <a id="required"></a> `required` | `true` | - |
|
|
905
741
|
|
|
906
742
|
### <a id="Validator"></a>Validator
|
|
907
743
|
|
|
@@ -913,23 +749,23 @@ Interface for validating objects and returning any errors found.
|
|
|
913
749
|
|
|
914
750
|
## Type Parameters
|
|
915
751
|
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
`T` *extends* [`EmptyObject`](#../type-aliases/EmptyObject)
|
|
752
|
+
| Type Parameter | Default type |
|
|
753
|
+
| ------ | ------ |
|
|
754
|
+
| `T` *extends* [`EmptyObject`](#../type-aliases/EmptyObject) | [`AnyObject`](#../type-aliases/AnyObject) |
|
|
919
755
|
|
|
920
756
|
## Methods
|
|
921
757
|
|
|
922
758
|
### validate()
|
|
923
759
|
|
|
924
760
|
```ts
|
|
925
|
-
validate(payload): Promisable<Error[]>;
|
|
761
|
+
validate(payload: T): Promisable<Error[]>;
|
|
926
762
|
```
|
|
927
763
|
|
|
928
764
|
### Parameters
|
|
929
765
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
`T`
|
|
766
|
+
| Parameter | Type |
|
|
767
|
+
| ------ | ------ |
|
|
768
|
+
| `payload` | `T` |
|
|
933
769
|
|
|
934
770
|
### Returns
|
|
935
771
|
|
|
@@ -957,28 +793,28 @@ will result in a type that includes the universal set of field names
|
|
|
957
793
|
***
|
|
958
794
|
|
|
959
795
|
```ts
|
|
960
|
-
type AsOptionalTypeFunction<T> = <TType>(value) => TType | undefined;
|
|
796
|
+
type AsOptionalTypeFunction<T> = <TType>(value: AnyNonPromise) => TType | undefined;
|
|
961
797
|
```
|
|
962
798
|
|
|
963
799
|
A simplified type-narrowing function that returns T or undefined, without assertion support.
|
|
964
800
|
|
|
965
801
|
## Type Parameters
|
|
966
802
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
`T` *extends* `AnyNonPromise`
|
|
803
|
+
| Type Parameter | Default type |
|
|
804
|
+
| ------ | ------ |
|
|
805
|
+
| `T` *extends* `AnyNonPromise` | `AnyNonPromise` |
|
|
970
806
|
|
|
971
807
|
## Type Parameters
|
|
972
808
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
`TType` *extends* `AnyNonPromise`
|
|
809
|
+
| Type Parameter |
|
|
810
|
+
| ------ |
|
|
811
|
+
| `TType` *extends* `AnyNonPromise` |
|
|
976
812
|
|
|
977
813
|
## Parameters
|
|
978
814
|
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
`AnyNonPromise`
|
|
815
|
+
| Parameter | Type |
|
|
816
|
+
| ------ | ------ |
|
|
817
|
+
| `value` | `AnyNonPromise` |
|
|
982
818
|
|
|
983
819
|
## Returns
|
|
984
820
|
|
|
@@ -992,12 +828,16 @@ A simplified type-narrowing function that returns T or undefined, without assert
|
|
|
992
828
|
|
|
993
829
|
```ts
|
|
994
830
|
type AsTypeFunction<T> = {
|
|
995
|
-
<TType> (value): TType | undefined;
|
|
996
|
-
<TType> (value, config): TType;
|
|
997
|
-
<TType> (value, config
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
<TType> (value, assert
|
|
831
|
+
<TType> (value: AnyNonPromise): TType | undefined;
|
|
832
|
+
<TType> (value: AnyNonPromise, config: TypeCheckRequiredConfig): TType;
|
|
833
|
+
<TType> (value: AnyNonPromise, config:
|
|
834
|
+
| TypeCheckConfig
|
|
835
|
+
| TypeCheckOptionalConfig): TType | undefined;
|
|
836
|
+
<TType> (value: AnyNonPromise, assert: StringOrAlertFunction<TType>): TType | undefined;
|
|
837
|
+
<TType> (value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config: TypeCheckRequiredConfig): TType;
|
|
838
|
+
<TType> (value: AnyNonPromise, assert: StringOrAlertFunction<TType>, config:
|
|
839
|
+
| TypeCheckConfig
|
|
840
|
+
| TypeCheckOptionalConfig): TType | undefined;
|
|
1001
841
|
};
|
|
1002
842
|
```
|
|
1003
843
|
|
|
@@ -1005,27 +845,27 @@ A type-narrowing function that attempts to cast a value to T, with optional asse
|
|
|
1005
845
|
|
|
1006
846
|
## Type Parameters
|
|
1007
847
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
`T` *extends* `AnyNonPromise`
|
|
848
|
+
| Type Parameter | Default type |
|
|
849
|
+
| ------ | ------ |
|
|
850
|
+
| `T` *extends* `AnyNonPromise` | `AnyNonPromise` |
|
|
1011
851
|
|
|
1012
852
|
## Call Signature
|
|
1013
853
|
|
|
1014
854
|
```ts
|
|
1015
|
-
<TType>(value): TType | undefined;
|
|
855
|
+
<TType>(value: AnyNonPromise): TType | undefined;
|
|
1016
856
|
```
|
|
1017
857
|
|
|
1018
858
|
### Type Parameters
|
|
1019
859
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
`TType` *extends* `AnyNonPromise`
|
|
860
|
+
| Type Parameter |
|
|
861
|
+
| ------ |
|
|
862
|
+
| `TType` *extends* `AnyNonPromise` |
|
|
1023
863
|
|
|
1024
864
|
### Parameters
|
|
1025
865
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
`AnyNonPromise`
|
|
866
|
+
| Parameter | Type |
|
|
867
|
+
| ------ | ------ |
|
|
868
|
+
| `value` | `AnyNonPromise` |
|
|
1029
869
|
|
|
1030
870
|
### Returns
|
|
1031
871
|
|
|
@@ -1034,24 +874,21 @@ A type-narrowing function that attempts to cast a value to T, with optional asse
|
|
|
1034
874
|
## Call Signature
|
|
1035
875
|
|
|
1036
876
|
```ts
|
|
1037
|
-
<TType>(value, config): TType;
|
|
877
|
+
<TType>(value: AnyNonPromise, config: TypeCheckRequiredConfig): TType;
|
|
1038
878
|
```
|
|
1039
879
|
|
|
1040
880
|
### Type Parameters
|
|
1041
881
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
`TType` *extends* `AnyNonPromise`
|
|
882
|
+
| Type Parameter |
|
|
883
|
+
| ------ |
|
|
884
|
+
| `TType` *extends* `AnyNonPromise` |
|
|
1045
885
|
|
|
1046
886
|
### Parameters
|
|
1047
887
|
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
`AnyNonPromise`
|
|
1051
|
-
|
|
1052
|
-
### config
|
|
1053
|
-
|
|
1054
|
-
[`TypeCheckRequiredConfig`](#../interfaces/TypeCheckRequiredConfig)
|
|
888
|
+
| Parameter | Type |
|
|
889
|
+
| ------ | ------ |
|
|
890
|
+
| `value` | `AnyNonPromise` |
|
|
891
|
+
| `config` | [`TypeCheckRequiredConfig`](#../interfaces/TypeCheckRequiredConfig) |
|
|
1055
892
|
|
|
1056
893
|
### Returns
|
|
1057
894
|
|
|
@@ -1060,24 +897,23 @@ A type-narrowing function that attempts to cast a value to T, with optional asse
|
|
|
1060
897
|
## Call Signature
|
|
1061
898
|
|
|
1062
899
|
```ts
|
|
1063
|
-
<TType>(value, config
|
|
900
|
+
<TType>(value: AnyNonPromise, config:
|
|
901
|
+
| TypeCheckConfig
|
|
902
|
+
| TypeCheckOptionalConfig): TType | undefined;
|
|
1064
903
|
```
|
|
1065
904
|
|
|
1066
905
|
### Type Parameters
|
|
1067
906
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
`TType` *extends* `AnyNonPromise`
|
|
907
|
+
| Type Parameter |
|
|
908
|
+
| ------ |
|
|
909
|
+
| `TType` *extends* `AnyNonPromise` |
|
|
1071
910
|
|
|
1072
911
|
### Parameters
|
|
1073
912
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
`AnyNonPromise`
|
|
1077
|
-
|
|
1078
|
-
### config
|
|
1079
|
-
|
|
1080
|
-
[`TypeCheckConfig`](#../interfaces/TypeCheckConfig) | [`TypeCheckOptionalConfig`](#../interfaces/TypeCheckOptionalConfig)
|
|
913
|
+
| Parameter | Type |
|
|
914
|
+
| ------ | ------ |
|
|
915
|
+
| `value` | `AnyNonPromise` |
|
|
916
|
+
| `config` | \| [`TypeCheckConfig`](#../interfaces/TypeCheckConfig) \| [`TypeCheckOptionalConfig`](#../interfaces/TypeCheckOptionalConfig) |
|
|
1081
917
|
|
|
1082
918
|
### Returns
|
|
1083
919
|
|
|
@@ -1086,24 +922,21 @@ A type-narrowing function that attempts to cast a value to T, with optional asse
|
|
|
1086
922
|
## Call Signature
|
|
1087
923
|
|
|
1088
924
|
```ts
|
|
1089
|
-
<TType>(value, assert): TType | undefined;
|
|
925
|
+
<TType>(value: AnyNonPromise, assert: StringOrAlertFunction<TType>): TType | undefined;
|
|
1090
926
|
```
|
|
1091
927
|
|
|
1092
928
|
### Type Parameters
|
|
1093
929
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
`TType` *extends* `AnyNonPromise`
|
|
930
|
+
| Type Parameter |
|
|
931
|
+
| ------ |
|
|
932
|
+
| `TType` *extends* `AnyNonPromise` |
|
|
1097
933
|
|
|
1098
934
|
### Parameters
|
|
1099
935
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
`AnyNonPromise`
|
|
1103
|
-
|
|
1104
|
-
### assert
|
|
1105
|
-
|
|
1106
|
-
[`StringOrAlertFunction`](#StringOrAlertFunction)\<`TType`\>
|
|
936
|
+
| Parameter | Type |
|
|
937
|
+
| ------ | ------ |
|
|
938
|
+
| `value` | `AnyNonPromise` |
|
|
939
|
+
| `assert` | [`StringOrAlertFunction`](#StringOrAlertFunction)\<`TType`\> |
|
|
1107
940
|
|
|
1108
941
|
### Returns
|
|
1109
942
|
|
|
@@ -1113,30 +946,24 @@ A type-narrowing function that attempts to cast a value to T, with optional asse
|
|
|
1113
946
|
|
|
1114
947
|
```ts
|
|
1115
948
|
<TType>(
|
|
1116
|
-
value,
|
|
1117
|
-
assert
|
|
1118
|
-
config): TType;
|
|
949
|
+
value: AnyNonPromise,
|
|
950
|
+
assert: StringOrAlertFunction<TType>,
|
|
951
|
+
config: TypeCheckRequiredConfig): TType;
|
|
1119
952
|
```
|
|
1120
953
|
|
|
1121
954
|
### Type Parameters
|
|
1122
955
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
`TType` *extends* `AnyNonPromise`
|
|
956
|
+
| Type Parameter |
|
|
957
|
+
| ------ |
|
|
958
|
+
| `TType` *extends* `AnyNonPromise` |
|
|
1126
959
|
|
|
1127
960
|
### Parameters
|
|
1128
961
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
`AnyNonPromise`
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
[`StringOrAlertFunction`](#StringOrAlertFunction)\<`TType`\>
|
|
1136
|
-
|
|
1137
|
-
### config
|
|
1138
|
-
|
|
1139
|
-
[`TypeCheckRequiredConfig`](#../interfaces/TypeCheckRequiredConfig)
|
|
962
|
+
| Parameter | Type |
|
|
963
|
+
| ------ | ------ |
|
|
964
|
+
| `value` | `AnyNonPromise` |
|
|
965
|
+
| `assert` | [`StringOrAlertFunction`](#StringOrAlertFunction)\<`TType`\> |
|
|
966
|
+
| `config` | [`TypeCheckRequiredConfig`](#../interfaces/TypeCheckRequiredConfig) |
|
|
1140
967
|
|
|
1141
968
|
### Returns
|
|
1142
969
|
|
|
@@ -1146,30 +973,26 @@ A type-narrowing function that attempts to cast a value to T, with optional asse
|
|
|
1146
973
|
|
|
1147
974
|
```ts
|
|
1148
975
|
<TType>(
|
|
1149
|
-
value,
|
|
1150
|
-
assert
|
|
1151
|
-
config
|
|
976
|
+
value: AnyNonPromise,
|
|
977
|
+
assert: StringOrAlertFunction<TType>,
|
|
978
|
+
config:
|
|
979
|
+
| TypeCheckConfig
|
|
980
|
+
| TypeCheckOptionalConfig): TType | undefined;
|
|
1152
981
|
```
|
|
1153
982
|
|
|
1154
983
|
### Type Parameters
|
|
1155
984
|
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
`TType` *extends* `AnyNonPromise`
|
|
985
|
+
| Type Parameter |
|
|
986
|
+
| ------ |
|
|
987
|
+
| `TType` *extends* `AnyNonPromise` |
|
|
1159
988
|
|
|
1160
989
|
### Parameters
|
|
1161
990
|
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
`AnyNonPromise`
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
[`StringOrAlertFunction`](#StringOrAlertFunction)\<`TType`\>
|
|
1169
|
-
|
|
1170
|
-
### config
|
|
1171
|
-
|
|
1172
|
-
[`TypeCheckConfig`](#../interfaces/TypeCheckConfig) | [`TypeCheckOptionalConfig`](#../interfaces/TypeCheckOptionalConfig)
|
|
991
|
+
| Parameter | Type |
|
|
992
|
+
| ------ | ------ |
|
|
993
|
+
| `value` | `AnyNonPromise` |
|
|
994
|
+
| `assert` | [`StringOrAlertFunction`](#StringOrAlertFunction)\<`TType`\> |
|
|
995
|
+
| `config` | \| [`TypeCheckConfig`](#../interfaces/TypeCheckConfig) \| [`TypeCheckOptionalConfig`](#../interfaces/TypeCheckOptionalConfig) |
|
|
1173
996
|
|
|
1174
997
|
### Returns
|
|
1175
998
|
|
|
@@ -1182,26 +1005,23 @@ A type-narrowing function that attempts to cast a value to T, with optional asse
|
|
|
1182
1005
|
***
|
|
1183
1006
|
|
|
1184
1007
|
```ts
|
|
1185
|
-
type Compare<T> = (a, b) => number;
|
|
1008
|
+
type Compare<T> = (a: T, b: T) => number;
|
|
1186
1009
|
```
|
|
1187
1010
|
|
|
1188
1011
|
A comparator function that returns a negative number if a < b, zero if a == b, and a positive number if a > b.
|
|
1189
1012
|
|
|
1190
1013
|
## Type Parameters
|
|
1191
1014
|
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
`T`
|
|
1015
|
+
| Type Parameter |
|
|
1016
|
+
| ------ |
|
|
1017
|
+
| `T` |
|
|
1195
1018
|
|
|
1196
1019
|
## Parameters
|
|
1197
1020
|
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
`T`
|
|
1201
|
-
|
|
1202
|
-
### b
|
|
1203
|
-
|
|
1204
|
-
`T`
|
|
1021
|
+
| Parameter | Type |
|
|
1022
|
+
| ------ | ------ |
|
|
1023
|
+
| `a` | `T` |
|
|
1024
|
+
| `b` | `T` |
|
|
1205
1025
|
|
|
1206
1026
|
## Returns
|
|
1207
1027
|
|
|
@@ -1221,13 +1041,10 @@ Recursively omits keys that start with the given prefix, including in nested obj
|
|
|
1221
1041
|
|
|
1222
1042
|
## Type Parameters
|
|
1223
1043
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
`T`
|
|
1227
|
-
|
|
1228
|
-
### Prefix
|
|
1229
|
-
|
|
1230
|
-
`Prefix` *extends* `string`
|
|
1044
|
+
| Type Parameter |
|
|
1045
|
+
| ------ |
|
|
1046
|
+
| `T` |
|
|
1047
|
+
| `Prefix` *extends* `string` |
|
|
1231
1048
|
|
|
1232
1049
|
### <a id="DeepPickStartsWith"></a>DeepPickStartsWith
|
|
1233
1050
|
|
|
@@ -1243,13 +1060,10 @@ Recursively picks only the keys that start with the given prefix, including in n
|
|
|
1243
1060
|
|
|
1244
1061
|
## Type Parameters
|
|
1245
1062
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
`T`
|
|
1249
|
-
|
|
1250
|
-
### Prefix
|
|
1251
|
-
|
|
1252
|
-
`Prefix` *extends* `string`
|
|
1063
|
+
| Type Parameter |
|
|
1064
|
+
| ------ |
|
|
1065
|
+
| `T` |
|
|
1066
|
+
| `Prefix` *extends* `string` |
|
|
1253
1067
|
|
|
1254
1068
|
### <a id="DeepRestrictToJson"></a>DeepRestrictToJson
|
|
1255
1069
|
|
|
@@ -1265,9 +1079,9 @@ Recursively restricts an object type to only JSON-compatible values, excluding n
|
|
|
1265
1079
|
|
|
1266
1080
|
## Type Parameters
|
|
1267
1081
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
`T`
|
|
1082
|
+
| Type Parameter |
|
|
1083
|
+
| ------ |
|
|
1084
|
+
| `T` |
|
|
1271
1085
|
|
|
1272
1086
|
### <a id="DeepRestrictToStringKeys"></a>DeepRestrictToStringKeys
|
|
1273
1087
|
|
|
@@ -1283,9 +1097,9 @@ Recursively removes all non-string keys from an object type, including in nested
|
|
|
1283
1097
|
|
|
1284
1098
|
## Type Parameters
|
|
1285
1099
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
`T`
|
|
1100
|
+
| Type Parameter |
|
|
1101
|
+
| ------ |
|
|
1102
|
+
| `T` |
|
|
1289
1103
|
|
|
1290
1104
|
### <a id="EmptyObject"></a>EmptyObject
|
|
1291
1105
|
|
|
@@ -1294,7 +1108,7 @@ Recursively removes all non-string keys from an object type, including in nested
|
|
|
1294
1108
|
***
|
|
1295
1109
|
|
|
1296
1110
|
```ts
|
|
1297
|
-
type EmptyObject<T> = Exclude<{ [K in keyof T]?: never }, unknown[] | (...args) => unknown | null>;
|
|
1111
|
+
type EmptyObject<T> = Exclude<{ [K in keyof T]?: never }, unknown[] | (...args: unknown[]) => unknown | null>;
|
|
1298
1112
|
```
|
|
1299
1113
|
|
|
1300
1114
|
An empty object, which means that it does enforce the set of field names, defaulting to an empty set until
|
|
@@ -1302,9 +1116,9 @@ extended from, which then adds only those additional fields
|
|
|
1302
1116
|
|
|
1303
1117
|
## Type Parameters
|
|
1304
1118
|
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
`T` *extends* `object`
|
|
1119
|
+
| Type Parameter | Default type |
|
|
1120
|
+
| ------ | ------ |
|
|
1121
|
+
| `T` *extends* `object` | `object` |
|
|
1308
1122
|
|
|
1309
1123
|
### <a id="JsonArray"></a>JsonArray
|
|
1310
1124
|
|
|
@@ -1349,26 +1163,23 @@ A recursive JSON value: string, number, boolean, null, array, or object.
|
|
|
1349
1163
|
***
|
|
1350
1164
|
|
|
1351
1165
|
```ts
|
|
1352
|
-
type OmitByPredicate<T> = (value, key) => boolean;
|
|
1166
|
+
type OmitByPredicate<T> = (value: T[keyof T], key: keyof T) => boolean;
|
|
1353
1167
|
```
|
|
1354
1168
|
|
|
1355
1169
|
A predicate function used to determine which properties to omit from an object.
|
|
1356
1170
|
|
|
1357
1171
|
## Type Parameters
|
|
1358
1172
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
`T` *extends* [`EmptyObject`](#EmptyObject)
|
|
1173
|
+
| Type Parameter | Default type |
|
|
1174
|
+
| ------ | ------ |
|
|
1175
|
+
| `T` *extends* [`EmptyObject`](#EmptyObject) | `Record`\<`string`, `unknown`\> |
|
|
1362
1176
|
|
|
1363
1177
|
## Parameters
|
|
1364
1178
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
`T`\[keyof `T`\]
|
|
1368
|
-
|
|
1369
|
-
### key
|
|
1370
|
-
|
|
1371
|
-
keyof `T`
|
|
1179
|
+
| Parameter | Type |
|
|
1180
|
+
| ------ | ------ |
|
|
1181
|
+
| `value` | `T`\[keyof `T`\] |
|
|
1182
|
+
| `key` | keyof `T` |
|
|
1372
1183
|
|
|
1373
1184
|
## Returns
|
|
1374
1185
|
|
|
@@ -1388,13 +1199,10 @@ Omits the keys of T that start with the given prefix.
|
|
|
1388
1199
|
|
|
1389
1200
|
## Type Parameters
|
|
1390
1201
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
`T`
|
|
1394
|
-
|
|
1395
|
-
### Prefix
|
|
1396
|
-
|
|
1397
|
-
`Prefix` *extends* `string`
|
|
1202
|
+
| Type Parameter |
|
|
1203
|
+
| ------ |
|
|
1204
|
+
| `T` |
|
|
1205
|
+
| `Prefix` *extends* `string` |
|
|
1398
1206
|
|
|
1399
1207
|
### <a id="Optional"></a>Optional
|
|
1400
1208
|
|
|
@@ -1410,13 +1218,10 @@ Makes the specified fields of T optional while keeping the rest required.
|
|
|
1410
1218
|
|
|
1411
1219
|
## Type Parameters
|
|
1412
1220
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
`T` *extends* `object`
|
|
1416
|
-
|
|
1417
|
-
### F
|
|
1418
|
-
|
|
1419
|
-
`F` *extends* keyof `T`
|
|
1221
|
+
| Type Parameter |
|
|
1222
|
+
| ------ |
|
|
1223
|
+
| `T` *extends* `object` |
|
|
1224
|
+
| `F` *extends* keyof `T` |
|
|
1420
1225
|
|
|
1421
1226
|
### <a id="Override"></a>Override
|
|
1422
1227
|
|
|
@@ -1432,13 +1237,10 @@ Overrides properties of T1 with those from T2.
|
|
|
1432
1237
|
|
|
1433
1238
|
## Type Parameters
|
|
1434
1239
|
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
`T1`
|
|
1438
|
-
|
|
1439
|
-
### T2
|
|
1440
|
-
|
|
1441
|
-
`T2`
|
|
1240
|
+
| Type Parameter |
|
|
1241
|
+
| ------ |
|
|
1242
|
+
| `T1` |
|
|
1243
|
+
| `T2` |
|
|
1442
1244
|
|
|
1443
1245
|
### <a id="PartialRecord"></a>PartialRecord
|
|
1444
1246
|
|
|
@@ -1452,13 +1254,10 @@ type PartialRecord<K, T> = { [P in K]?: T };
|
|
|
1452
1254
|
|
|
1453
1255
|
## Type Parameters
|
|
1454
1256
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
`K` *extends* keyof `any`
|
|
1458
|
-
|
|
1459
|
-
### T
|
|
1460
|
-
|
|
1461
|
-
`T`
|
|
1257
|
+
| Type Parameter |
|
|
1258
|
+
| ------ |
|
|
1259
|
+
| `K` *extends* keyof `any` |
|
|
1260
|
+
| `T` |
|
|
1462
1261
|
|
|
1463
1262
|
## Deprecated
|
|
1464
1263
|
|
|
@@ -1471,26 +1270,23 @@ use Partial<Record<>> instead
|
|
|
1471
1270
|
***
|
|
1472
1271
|
|
|
1473
1272
|
```ts
|
|
1474
|
-
type PickByPredicate<T> = (value, key) => boolean;
|
|
1273
|
+
type PickByPredicate<T> = (value: T[keyof T], key: keyof T) => boolean;
|
|
1475
1274
|
```
|
|
1476
1275
|
|
|
1477
1276
|
A predicate function used to determine which properties to pick from an object.
|
|
1478
1277
|
|
|
1479
1278
|
## Type Parameters
|
|
1480
1279
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
`T` *extends* [`EmptyObject`](#EmptyObject)
|
|
1280
|
+
| Type Parameter | Default type |
|
|
1281
|
+
| ------ | ------ |
|
|
1282
|
+
| `T` *extends* [`EmptyObject`](#EmptyObject) | `Record`\<`string`, `unknown`\> |
|
|
1484
1283
|
|
|
1485
1284
|
## Parameters
|
|
1486
1285
|
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
`T`\[keyof `T`\]
|
|
1490
|
-
|
|
1491
|
-
### key
|
|
1492
|
-
|
|
1493
|
-
keyof `T`
|
|
1286
|
+
| Parameter | Type |
|
|
1287
|
+
| ------ | ------ |
|
|
1288
|
+
| `value` | `T`\[keyof `T`\] |
|
|
1289
|
+
| `key` | keyof `T` |
|
|
1494
1290
|
|
|
1495
1291
|
## Returns
|
|
1496
1292
|
|
|
@@ -1510,13 +1306,10 @@ Picks only the keys of T that start with the given prefix.
|
|
|
1510
1306
|
|
|
1511
1307
|
## Type Parameters
|
|
1512
1308
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
`T`
|
|
1516
|
-
|
|
1517
|
-
### Prefix
|
|
1518
|
-
|
|
1519
|
-
`Prefix` *extends* `string`
|
|
1309
|
+
| Type Parameter |
|
|
1310
|
+
| ------ |
|
|
1311
|
+
| `T` |
|
|
1312
|
+
| `Prefix` *extends* `string` |
|
|
1520
1313
|
|
|
1521
1314
|
### <a id="Simplify"></a>Simplify
|
|
1522
1315
|
|
|
@@ -1525,16 +1318,17 @@ Picks only the keys of T that start with the given prefix.
|
|
|
1525
1318
|
***
|
|
1526
1319
|
|
|
1527
1320
|
```ts
|
|
1528
|
-
type Simplify<T> = { [K in keyof T]: T[K] } &
|
|
1321
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & {
|
|
1322
|
+
};
|
|
1529
1323
|
```
|
|
1530
1324
|
|
|
1531
1325
|
Flattens an intersection or complex mapped type into a single object type for better readability.
|
|
1532
1326
|
|
|
1533
1327
|
## Type Parameters
|
|
1534
1328
|
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
`T`
|
|
1329
|
+
| Type Parameter |
|
|
1330
|
+
| ------ |
|
|
1331
|
+
| `T` |
|
|
1538
1332
|
|
|
1539
1333
|
### <a id="StringKeyObject"></a>StringKeyObject
|
|
1540
1334
|
|
|
@@ -1543,16 +1337,18 @@ Flattens an intersection or complex mapped type into a single object type for be
|
|
|
1543
1337
|
***
|
|
1544
1338
|
|
|
1545
1339
|
```ts
|
|
1546
|
-
type StringKeyObject<T> =
|
|
1340
|
+
type StringKeyObject<T> = {
|
|
1341
|
+
[key: string]: T;
|
|
1342
|
+
};
|
|
1547
1343
|
```
|
|
1548
1344
|
|
|
1549
1345
|
An object type with string keys and values of type T.
|
|
1550
1346
|
|
|
1551
1347
|
## Type Parameters
|
|
1552
1348
|
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
`T`
|
|
1349
|
+
| Type Parameter | Default type |
|
|
1350
|
+
| ------ | ------ |
|
|
1351
|
+
| `T` | `unknown` |
|
|
1556
1352
|
|
|
1557
1353
|
## Index Signature
|
|
1558
1354
|
|
|
@@ -1574,9 +1370,9 @@ A string message or function that produces an assertion error message for a fail
|
|
|
1574
1370
|
|
|
1575
1371
|
## Type Parameters
|
|
1576
1372
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
`T` *extends* `AnyNonPromise`
|
|
1373
|
+
| Type Parameter |
|
|
1374
|
+
| ------ |
|
|
1375
|
+
| `T` *extends* `AnyNonPromise` |
|
|
1580
1376
|
|
|
1581
1377
|
### <a id="TypeCheck"></a>TypeCheck
|
|
1582
1378
|
|
|
@@ -1586,9 +1382,12 @@ A string message or function that produces an assertion error message for a fail
|
|
|
1586
1382
|
|
|
1587
1383
|
```ts
|
|
1588
1384
|
type TypeCheck<T> = {
|
|
1589
|
-
(obj): obj is T;
|
|
1590
|
-
(obj, config): obj is T;
|
|
1591
|
-
(obj, config
|
|
1385
|
+
(obj: AnyNonPromise): obj is T;
|
|
1386
|
+
(obj: AnyNonPromise, config: TypeCheckConfig): obj is T;
|
|
1387
|
+
(obj: AnyNonPromise, config:
|
|
1388
|
+
| number
|
|
1389
|
+
| TypeCheckConfig
|
|
1390
|
+
| undefined): obj is T;
|
|
1592
1391
|
};
|
|
1593
1392
|
```
|
|
1594
1393
|
|
|
@@ -1596,21 +1395,21 @@ A type guard function that checks whether a value conforms to type T, with optio
|
|
|
1596
1395
|
|
|
1597
1396
|
## Type Parameters
|
|
1598
1397
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
`T` *extends* `TypedValue`
|
|
1398
|
+
| Type Parameter |
|
|
1399
|
+
| ------ |
|
|
1400
|
+
| `T` *extends* `TypedValue` |
|
|
1602
1401
|
|
|
1603
1402
|
## Call Signature
|
|
1604
1403
|
|
|
1605
1404
|
```ts
|
|
1606
|
-
(obj): obj is T;
|
|
1405
|
+
(obj: AnyNonPromise): obj is T;
|
|
1607
1406
|
```
|
|
1608
1407
|
|
|
1609
1408
|
### Parameters
|
|
1610
1409
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
`AnyNonPromise`
|
|
1410
|
+
| Parameter | Type |
|
|
1411
|
+
| ------ | ------ |
|
|
1412
|
+
| `obj` | `AnyNonPromise` |
|
|
1614
1413
|
|
|
1615
1414
|
### Returns
|
|
1616
1415
|
|
|
@@ -1619,18 +1418,15 @@ A type guard function that checks whether a value conforms to type T, with optio
|
|
|
1619
1418
|
## Call Signature
|
|
1620
1419
|
|
|
1621
1420
|
```ts
|
|
1622
|
-
(obj, config): obj is T;
|
|
1421
|
+
(obj: AnyNonPromise, config: TypeCheckConfig): obj is T;
|
|
1623
1422
|
```
|
|
1624
1423
|
|
|
1625
1424
|
### Parameters
|
|
1626
1425
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
`AnyNonPromise`
|
|
1630
|
-
|
|
1631
|
-
### config
|
|
1632
|
-
|
|
1633
|
-
[`TypeCheckConfig`](#../interfaces/TypeCheckConfig)
|
|
1426
|
+
| Parameter | Type |
|
|
1427
|
+
| ------ | ------ |
|
|
1428
|
+
| `obj` | `AnyNonPromise` |
|
|
1429
|
+
| `config` | [`TypeCheckConfig`](#../interfaces/TypeCheckConfig) |
|
|
1634
1430
|
|
|
1635
1431
|
### Returns
|
|
1636
1432
|
|
|
@@ -1639,18 +1435,18 @@ A type guard function that checks whether a value conforms to type T, with optio
|
|
|
1639
1435
|
## Call Signature
|
|
1640
1436
|
|
|
1641
1437
|
```ts
|
|
1642
|
-
(obj, config
|
|
1438
|
+
(obj: AnyNonPromise, config:
|
|
1439
|
+
| number
|
|
1440
|
+
| TypeCheckConfig
|
|
1441
|
+
| undefined): obj is T;
|
|
1643
1442
|
```
|
|
1644
1443
|
|
|
1645
1444
|
### Parameters
|
|
1646
1445
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
`AnyNonPromise`
|
|
1650
|
-
|
|
1651
|
-
### config
|
|
1652
|
-
|
|
1653
|
-
`number` | [`TypeCheckConfig`](#../interfaces/TypeCheckConfig) | `undefined`
|
|
1446
|
+
| Parameter | Type |
|
|
1447
|
+
| ------ | ------ |
|
|
1448
|
+
| `obj` | `AnyNonPromise` |
|
|
1449
|
+
| `config` | \| `number` \| [`TypeCheckConfig`](#../interfaces/TypeCheckConfig) \| `undefined` |
|
|
1654
1450
|
|
|
1655
1451
|
### Returns
|
|
1656
1452
|
|
|
@@ -1670,13 +1466,10 @@ Intersects T with TAdditional if TAdditional is an object, otherwise returns T u
|
|
|
1670
1466
|
|
|
1671
1467
|
## Type Parameters
|
|
1672
1468
|
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
`T` *extends* [`EmptyObject`](#EmptyObject) \| `void`
|
|
1676
|
-
|
|
1677
|
-
### TAdditional
|
|
1678
|
-
|
|
1679
|
-
`TAdditional` *extends* [`EmptyObject`](#EmptyObject) \| `void` = `void`
|
|
1469
|
+
| Type Parameter | Default type |
|
|
1470
|
+
| ------ | ------ |
|
|
1471
|
+
| `T` *extends* [`EmptyObject`](#EmptyObject) \| `void` | - |
|
|
1472
|
+
| `TAdditional` *extends* [`EmptyObject`](#EmptyObject) \| `void` | `void` |
|
|
1680
1473
|
|
|
1681
1474
|
### variables
|
|
1682
1475
|
|
|
@@ -1687,68 +1480,20 @@ Intersects T with TAdditional if TAdditional is an object, otherwise returns T u
|
|
|
1687
1480
|
***
|
|
1688
1481
|
|
|
1689
1482
|
```ts
|
|
1690
|
-
const AsObjectFactory:
|
|
1483
|
+
const AsObjectFactory: {
|
|
1484
|
+
create: <T>(typeCheck: TypeCheck<T>) => AsTypeFunction<T>;
|
|
1485
|
+
createOptional: <T>(typeCheck: TypeCheck<T>) => (value: AnyNonPromise) => T | undefined;
|
|
1486
|
+
};
|
|
1691
1487
|
```
|
|
1692
1488
|
|
|
1693
1489
|
Factory for creating type-narrowing functions for TypedObject types.
|
|
1694
1490
|
|
|
1695
1491
|
## Type Declaration
|
|
1696
1492
|
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
```
|
|
1702
|
-
|
|
1703
|
-
### Type Parameters
|
|
1704
|
-
|
|
1705
|
-
#### T
|
|
1706
|
-
|
|
1707
|
-
`T` *extends* `TypedObject`
|
|
1708
|
-
|
|
1709
|
-
### Parameters
|
|
1710
|
-
|
|
1711
|
-
#### typeCheck
|
|
1712
|
-
|
|
1713
|
-
[`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>
|
|
1714
|
-
|
|
1715
|
-
### Returns
|
|
1716
|
-
|
|
1717
|
-
[`AsTypeFunction`](#../type-aliases/AsTypeFunction)\<`T`\>
|
|
1718
|
-
|
|
1719
|
-
### createOptional()
|
|
1720
|
-
|
|
1721
|
-
```ts
|
|
1722
|
-
createOptional: <T>(typeCheck) => (value) => T | undefined;
|
|
1723
|
-
```
|
|
1724
|
-
|
|
1725
|
-
### Type Parameters
|
|
1726
|
-
|
|
1727
|
-
#### T
|
|
1728
|
-
|
|
1729
|
-
`T` *extends* `TypedObject`
|
|
1730
|
-
|
|
1731
|
-
### Parameters
|
|
1732
|
-
|
|
1733
|
-
#### typeCheck
|
|
1734
|
-
|
|
1735
|
-
[`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>
|
|
1736
|
-
|
|
1737
|
-
### Returns
|
|
1738
|
-
|
|
1739
|
-
```ts
|
|
1740
|
-
(value): T | undefined;
|
|
1741
|
-
```
|
|
1742
|
-
|
|
1743
|
-
#### Parameters
|
|
1744
|
-
|
|
1745
|
-
##### value
|
|
1746
|
-
|
|
1747
|
-
`AnyNonPromise`
|
|
1748
|
-
|
|
1749
|
-
#### Returns
|
|
1750
|
-
|
|
1751
|
-
`T` \| `undefined`
|
|
1493
|
+
| Name | Type |
|
|
1494
|
+
| ------ | ------ |
|
|
1495
|
+
| <a id="property-create"></a> `create()` | \<`T`\>(`typeCheck`: [`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>) => [`AsTypeFunction`](#../type-aliases/AsTypeFunction)\<`T`\> |
|
|
1496
|
+
| <a id="property-createoptional"></a> `createOptional()` | \<`T`\>(`typeCheck`: [`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>) => (`value`: `AnyNonPromise`) => `T` \| `undefined` |
|
|
1752
1497
|
|
|
1753
1498
|
### <a id="AsTypeFactory"></a>AsTypeFactory
|
|
1754
1499
|
|
|
@@ -1757,7 +1502,10 @@ createOptional: <T>(typeCheck) => (value) => T | undefined;
|
|
|
1757
1502
|
***
|
|
1758
1503
|
|
|
1759
1504
|
```ts
|
|
1760
|
-
const AsTypeFactory:
|
|
1505
|
+
const AsTypeFactory: {
|
|
1506
|
+
create: <T>(typeCheck: TypeCheck<T>) => AsTypeFunction<T>;
|
|
1507
|
+
createOptional: <T>(typeCheck: TypeCheck<T>) => (value: AnyNonPromise) => T | undefined;
|
|
1508
|
+
};
|
|
1761
1509
|
```
|
|
1762
1510
|
|
|
1763
1511
|
Factory for creating type-narrowing 'as' functions that cast a value to T or return undefined.
|
|
@@ -1765,61 +1513,10 @@ Supports optional assertion messages and configuration for required/optional beh
|
|
|
1765
1513
|
|
|
1766
1514
|
## Type Declaration
|
|
1767
1515
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
```
|
|
1773
|
-
|
|
1774
|
-
### Type Parameters
|
|
1775
|
-
|
|
1776
|
-
#### T
|
|
1777
|
-
|
|
1778
|
-
`T` *extends* `AnyNonPromise`
|
|
1779
|
-
|
|
1780
|
-
### Parameters
|
|
1781
|
-
|
|
1782
|
-
#### typeCheck
|
|
1783
|
-
|
|
1784
|
-
[`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>
|
|
1785
|
-
|
|
1786
|
-
### Returns
|
|
1787
|
-
|
|
1788
|
-
[`AsTypeFunction`](#../type-aliases/AsTypeFunction)\<`T`\>
|
|
1789
|
-
|
|
1790
|
-
### createOptional()
|
|
1791
|
-
|
|
1792
|
-
```ts
|
|
1793
|
-
createOptional: <T>(typeCheck) => (value) => T | undefined;
|
|
1794
|
-
```
|
|
1795
|
-
|
|
1796
|
-
### Type Parameters
|
|
1797
|
-
|
|
1798
|
-
#### T
|
|
1799
|
-
|
|
1800
|
-
`T` *extends* `AnyNonPromise`
|
|
1801
|
-
|
|
1802
|
-
### Parameters
|
|
1803
|
-
|
|
1804
|
-
#### typeCheck
|
|
1805
|
-
|
|
1806
|
-
[`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>
|
|
1807
|
-
|
|
1808
|
-
### Returns
|
|
1809
|
-
|
|
1810
|
-
```ts
|
|
1811
|
-
(value): T | undefined;
|
|
1812
|
-
```
|
|
1813
|
-
|
|
1814
|
-
#### Parameters
|
|
1815
|
-
|
|
1816
|
-
##### value
|
|
1817
|
-
|
|
1818
|
-
`AnyNonPromise`
|
|
1819
|
-
|
|
1820
|
-
#### Returns
|
|
1821
|
-
|
|
1822
|
-
`T` \| `undefined`
|
|
1516
|
+
| Name | Type |
|
|
1517
|
+
| ------ | ------ |
|
|
1518
|
+
| <a id="property-create"></a> `create()` | \<`T`\>(`typeCheck`: [`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>) => [`AsTypeFunction`](#../type-aliases/AsTypeFunction)\<`T`\> |
|
|
1519
|
+
| <a id="property-createoptional"></a> `createOptional()` | \<`T`\>(`typeCheck`: [`TypeCheck`](#../type-aliases/TypeCheck)\<`T`\>) => (`value`: `AnyNonPromise`) => `T` \| `undefined` |
|
|
1823
1520
|
|
|
1824
1521
|
### <a id="JsonObjectZod"></a>JsonObjectZod
|
|
1825
1522
|
|
|
@@ -1853,8 +1550,8 @@ Type-narrowing function that casts a value to AnyObject if it is a plain object,
|
|
|
1853
1550
|
|
|
1854
1551
|
```ts
|
|
1855
1552
|
const asJsonArray: {
|
|
1856
|
-
<T> (value): T & unknown[] | undefined;
|
|
1857
|
-
<T> (value, assert): T & unknown[];
|
|
1553
|
+
<T> (value: T): T & unknown[] | undefined;
|
|
1554
|
+
<T> (value: T, assert: ZodFactoryConfig): T & unknown[];
|
|
1858
1555
|
};
|
|
1859
1556
|
```
|
|
1860
1557
|
|
|
@@ -1863,20 +1560,20 @@ Casts a value to JsonArray or returns undefined if it does not conform.
|
|
|
1863
1560
|
## Call Signature
|
|
1864
1561
|
|
|
1865
1562
|
```ts
|
|
1866
|
-
<T>(value): T & unknown[] | undefined;
|
|
1563
|
+
<T>(value: T): T & unknown[] | undefined;
|
|
1867
1564
|
```
|
|
1868
1565
|
|
|
1869
1566
|
### Type Parameters
|
|
1870
1567
|
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
`T`
|
|
1568
|
+
| Type Parameter |
|
|
1569
|
+
| ------ |
|
|
1570
|
+
| `T` |
|
|
1874
1571
|
|
|
1875
1572
|
### Parameters
|
|
1876
1573
|
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
`T`
|
|
1574
|
+
| Parameter | Type |
|
|
1575
|
+
| ------ | ------ |
|
|
1576
|
+
| `value` | `T` |
|
|
1880
1577
|
|
|
1881
1578
|
### Returns
|
|
1882
1579
|
|
|
@@ -1885,24 +1582,21 @@ Casts a value to JsonArray or returns undefined if it does not conform.
|
|
|
1885
1582
|
## Call Signature
|
|
1886
1583
|
|
|
1887
1584
|
```ts
|
|
1888
|
-
<T>(value, assert): T & unknown[];
|
|
1585
|
+
<T>(value: T, assert: ZodFactoryConfig): T & unknown[];
|
|
1889
1586
|
```
|
|
1890
1587
|
|
|
1891
1588
|
### Type Parameters
|
|
1892
1589
|
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
`T`
|
|
1590
|
+
| Type Parameter |
|
|
1591
|
+
| ------ |
|
|
1592
|
+
| `T` |
|
|
1896
1593
|
|
|
1897
1594
|
### Parameters
|
|
1898
1595
|
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
`T`
|
|
1902
|
-
|
|
1903
|
-
### assert
|
|
1904
|
-
|
|
1905
|
-
`ZodFactoryConfig`
|
|
1596
|
+
| Parameter | Type |
|
|
1597
|
+
| ------ | ------ |
|
|
1598
|
+
| `value` | `T` |
|
|
1599
|
+
| `assert` | `ZodFactoryConfig` |
|
|
1906
1600
|
|
|
1907
1601
|
### Returns
|
|
1908
1602
|
|
|
@@ -1916,8 +1610,8 @@ Casts a value to JsonArray or returns undefined if it does not conform.
|
|
|
1916
1610
|
|
|
1917
1611
|
```ts
|
|
1918
1612
|
const asJsonObject: {
|
|
1919
|
-
<T> (value): T & Record<string, unknown> | undefined;
|
|
1920
|
-
<T> (value, assert): T & Record<string, unknown>;
|
|
1613
|
+
<T> (value: T): T & Record<string, unknown> | undefined;
|
|
1614
|
+
<T> (value: T, assert: ZodFactoryConfig): T & Record<string, unknown>;
|
|
1921
1615
|
};
|
|
1922
1616
|
```
|
|
1923
1617
|
|
|
@@ -1926,20 +1620,20 @@ Casts a value to JsonObject or returns undefined if it does not conform.
|
|
|
1926
1620
|
## Call Signature
|
|
1927
1621
|
|
|
1928
1622
|
```ts
|
|
1929
|
-
<T>(value): T & Record<string, unknown> | undefined;
|
|
1623
|
+
<T>(value: T): T & Record<string, unknown> | undefined;
|
|
1930
1624
|
```
|
|
1931
1625
|
|
|
1932
1626
|
### Type Parameters
|
|
1933
1627
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
`T`
|
|
1628
|
+
| Type Parameter |
|
|
1629
|
+
| ------ |
|
|
1630
|
+
| `T` |
|
|
1937
1631
|
|
|
1938
1632
|
### Parameters
|
|
1939
1633
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
`T`
|
|
1634
|
+
| Parameter | Type |
|
|
1635
|
+
| ------ | ------ |
|
|
1636
|
+
| `value` | `T` |
|
|
1943
1637
|
|
|
1944
1638
|
### Returns
|
|
1945
1639
|
|
|
@@ -1948,24 +1642,21 @@ Casts a value to JsonObject or returns undefined if it does not conform.
|
|
|
1948
1642
|
## Call Signature
|
|
1949
1643
|
|
|
1950
1644
|
```ts
|
|
1951
|
-
<T>(value, assert): T & Record<string, unknown>;
|
|
1645
|
+
<T>(value: T, assert: ZodFactoryConfig): T & Record<string, unknown>;
|
|
1952
1646
|
```
|
|
1953
1647
|
|
|
1954
1648
|
### Type Parameters
|
|
1955
1649
|
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
`T`
|
|
1650
|
+
| Type Parameter |
|
|
1651
|
+
| ------ |
|
|
1652
|
+
| `T` |
|
|
1959
1653
|
|
|
1960
1654
|
### Parameters
|
|
1961
1655
|
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
`T`
|
|
1965
|
-
|
|
1966
|
-
### assert
|
|
1967
|
-
|
|
1968
|
-
`ZodFactoryConfig`
|
|
1656
|
+
| Parameter | Type |
|
|
1657
|
+
| ------ | ------ |
|
|
1658
|
+
| `value` | `T` |
|
|
1659
|
+
| `assert` | `ZodFactoryConfig` |
|
|
1969
1660
|
|
|
1970
1661
|
### Returns
|
|
1971
1662
|
|
|
@@ -1979,8 +1670,8 @@ Casts a value to JsonObject or returns undefined if it does not conform.
|
|
|
1979
1670
|
|
|
1980
1671
|
```ts
|
|
1981
1672
|
const asJsonValue: {
|
|
1982
|
-
<T> (value): T | undefined;
|
|
1983
|
-
<T> (value, assert): T;
|
|
1673
|
+
<T> (value: T): T | undefined;
|
|
1674
|
+
<T> (value: T, assert: ZodFactoryConfig): T;
|
|
1984
1675
|
};
|
|
1985
1676
|
```
|
|
1986
1677
|
|
|
@@ -1989,20 +1680,20 @@ Casts a value to JsonValue or returns undefined if it does not conform.
|
|
|
1989
1680
|
## Call Signature
|
|
1990
1681
|
|
|
1991
1682
|
```ts
|
|
1992
|
-
<T>(value): T | undefined;
|
|
1683
|
+
<T>(value: T): T | undefined;
|
|
1993
1684
|
```
|
|
1994
1685
|
|
|
1995
1686
|
### Type Parameters
|
|
1996
1687
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
`T`
|
|
1688
|
+
| Type Parameter |
|
|
1689
|
+
| ------ |
|
|
1690
|
+
| `T` |
|
|
2000
1691
|
|
|
2001
1692
|
### Parameters
|
|
2002
1693
|
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
`T`
|
|
1694
|
+
| Parameter | Type |
|
|
1695
|
+
| ------ | ------ |
|
|
1696
|
+
| `value` | `T` |
|
|
2006
1697
|
|
|
2007
1698
|
### Returns
|
|
2008
1699
|
|
|
@@ -2011,24 +1702,21 @@ Casts a value to JsonValue or returns undefined if it does not conform.
|
|
|
2011
1702
|
## Call Signature
|
|
2012
1703
|
|
|
2013
1704
|
```ts
|
|
2014
|
-
<T>(value, assert): T;
|
|
1705
|
+
<T>(value: T, assert: ZodFactoryConfig): T;
|
|
2015
1706
|
```
|
|
2016
1707
|
|
|
2017
1708
|
### Type Parameters
|
|
2018
1709
|
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
`T`
|
|
1710
|
+
| Type Parameter |
|
|
1711
|
+
| ------ |
|
|
1712
|
+
| `T` |
|
|
2022
1713
|
|
|
2023
1714
|
### Parameters
|
|
2024
1715
|
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
`T`
|
|
2028
|
-
|
|
2029
|
-
### assert
|
|
2030
|
-
|
|
2031
|
-
`ZodFactoryConfig`
|
|
1716
|
+
| Parameter | Type |
|
|
1717
|
+
| ------ | ------ |
|
|
1718
|
+
| `value` | `T` |
|
|
1719
|
+
| `assert` | `ZodFactoryConfig` |
|
|
2032
1720
|
|
|
2033
1721
|
### Returns
|
|
2034
1722
|
|
|
@@ -2041,31 +1729,22 @@ Casts a value to JsonValue or returns undefined if it does not conform.
|
|
|
2041
1729
|
***
|
|
2042
1730
|
|
|
2043
1731
|
```ts
|
|
2044
|
-
const deepMerge: <T>(...objects) => MergeAll<T>;
|
|
1732
|
+
const deepMerge: <T>(...objects: T) => MergeAll<T>;
|
|
2045
1733
|
```
|
|
2046
1734
|
|
|
2047
1735
|
Deeply merges multiple objects into a new object.
|
|
2048
1736
|
|
|
2049
1737
|
## Type Parameters
|
|
2050
1738
|
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
`T` *extends* [`AnyObject`](#../type-aliases/AnyObject)[]
|
|
1739
|
+
| Type Parameter |
|
|
1740
|
+
| ------ |
|
|
1741
|
+
| `T` *extends* [`AnyObject`](#../type-aliases/AnyObject)[] |
|
|
2054
1742
|
|
|
2055
1743
|
## Parameters
|
|
2056
1744
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
...`T`
|
|
2060
|
-
|
|
2061
|
-
Multiple objects to merge deeply.
|
|
2062
|
-
The function merges properties from all objects into a new object.
|
|
2063
|
-
If a property exists in multiple objects, the last object's value will be used.
|
|
2064
|
-
If a property is an object, it will be merged recursively.
|
|
2065
|
-
If a property is an array, it will be overwritten by the last object's value.
|
|
2066
|
-
If a property is a primitive value, it will be overwritten by the last object's value.
|
|
2067
|
-
If a property is undefined in the source, it will be skipped.
|
|
2068
|
-
If a property is a symbol, it will be merged as well.
|
|
1745
|
+
| Parameter | Type | Description |
|
|
1746
|
+
| ------ | ------ | ------ |
|
|
1747
|
+
| ...`objects` | `T` | Multiple objects to merge deeply. The function merges properties from all objects into a new object. If a property exists in multiple objects, the last object's value will be used. If a property is an object, it will be merged recursively. If a property is an array, it will be overwritten by the last object's value. If a property is a primitive value, it will be overwritten by the last object's value. If a property is undefined in the source, it will be skipped. If a property is a symbol, it will be merged as well. |
|
|
2069
1748
|
|
|
2070
1749
|
## Returns
|
|
2071
1750
|
|
|
@@ -2080,22 +1759,22 @@ A new object with the merged properties.
|
|
|
2080
1759
|
***
|
|
2081
1760
|
|
|
2082
1761
|
```ts
|
|
2083
|
-
const isJsonArray: <T>(value) => value is T & unknown[];
|
|
1762
|
+
const isJsonArray: <T>(value: T) => value is T & unknown[];
|
|
2084
1763
|
```
|
|
2085
1764
|
|
|
2086
1765
|
Type guard that checks if a value is a valid JSON array.
|
|
2087
1766
|
|
|
2088
1767
|
## Type Parameters
|
|
2089
1768
|
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
`T`
|
|
1769
|
+
| Type Parameter |
|
|
1770
|
+
| ------ |
|
|
1771
|
+
| `T` |
|
|
2093
1772
|
|
|
2094
1773
|
## Parameters
|
|
2095
1774
|
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
`T`
|
|
1775
|
+
| Parameter | Type |
|
|
1776
|
+
| ------ | ------ |
|
|
1777
|
+
| `value` | `T` |
|
|
2099
1778
|
|
|
2100
1779
|
## Returns
|
|
2101
1780
|
|
|
@@ -2108,22 +1787,22 @@ Type guard that checks if a value is a valid JSON array.
|
|
|
2108
1787
|
***
|
|
2109
1788
|
|
|
2110
1789
|
```ts
|
|
2111
|
-
const isJsonObject: <T>(value) => value is T & Record<string, unknown>;
|
|
1790
|
+
const isJsonObject: <T>(value: T) => value is T & Record<string, unknown>;
|
|
2112
1791
|
```
|
|
2113
1792
|
|
|
2114
1793
|
Type guard that checks if a value is a valid JSON object.
|
|
2115
1794
|
|
|
2116
1795
|
## Type Parameters
|
|
2117
1796
|
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
`T`
|
|
1797
|
+
| Type Parameter |
|
|
1798
|
+
| ------ |
|
|
1799
|
+
| `T` |
|
|
2121
1800
|
|
|
2122
1801
|
## Parameters
|
|
2123
1802
|
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
`T`
|
|
1803
|
+
| Parameter | Type |
|
|
1804
|
+
| ------ | ------ |
|
|
1805
|
+
| `value` | `T` |
|
|
2127
1806
|
|
|
2128
1807
|
## Returns
|
|
2129
1808
|
|
|
@@ -2136,22 +1815,22 @@ Type guard that checks if a value is a valid JSON object.
|
|
|
2136
1815
|
***
|
|
2137
1816
|
|
|
2138
1817
|
```ts
|
|
2139
|
-
const isJsonValue: <T>(value) => value is T;
|
|
1818
|
+
const isJsonValue: <T>(value: T) => value is T;
|
|
2140
1819
|
```
|
|
2141
1820
|
|
|
2142
1821
|
Type guard that checks if a value is a valid JSON value.
|
|
2143
1822
|
|
|
2144
1823
|
## Type Parameters
|
|
2145
1824
|
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
`T`
|
|
1825
|
+
| Type Parameter |
|
|
1826
|
+
| ------ |
|
|
1827
|
+
| `T` |
|
|
2149
1828
|
|
|
2150
1829
|
## Parameters
|
|
2151
1830
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
`T`
|
|
1831
|
+
| Parameter | Type |
|
|
1832
|
+
| ------ | ------ |
|
|
1833
|
+
| `value` | `T` |
|
|
2155
1834
|
|
|
2156
1835
|
## Returns
|
|
2157
1836
|
|
|
@@ -2165,8 +1844,8 @@ Type guard that checks if a value is a valid JSON value.
|
|
|
2165
1844
|
|
|
2166
1845
|
```ts
|
|
2167
1846
|
const toJsonArray: {
|
|
2168
|
-
<T> (value): T & unknown[] | undefined;
|
|
2169
|
-
<T> (value, assert): T & unknown[];
|
|
1847
|
+
<T> (value: T): T & unknown[] | undefined;
|
|
1848
|
+
<T> (value: T, assert: ZodFactoryConfig): T & unknown[];
|
|
2170
1849
|
};
|
|
2171
1850
|
```
|
|
2172
1851
|
|
|
@@ -2175,20 +1854,20 @@ Parses a value into a JsonArray, throwing if it does not conform.
|
|
|
2175
1854
|
## Call Signature
|
|
2176
1855
|
|
|
2177
1856
|
```ts
|
|
2178
|
-
<T>(value): T & unknown[] | undefined;
|
|
1857
|
+
<T>(value: T): T & unknown[] | undefined;
|
|
2179
1858
|
```
|
|
2180
1859
|
|
|
2181
1860
|
### Type Parameters
|
|
2182
1861
|
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
`T`
|
|
1862
|
+
| Type Parameter |
|
|
1863
|
+
| ------ |
|
|
1864
|
+
| `T` |
|
|
2186
1865
|
|
|
2187
1866
|
### Parameters
|
|
2188
1867
|
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
`T`
|
|
1868
|
+
| Parameter | Type |
|
|
1869
|
+
| ------ | ------ |
|
|
1870
|
+
| `value` | `T` |
|
|
2192
1871
|
|
|
2193
1872
|
### Returns
|
|
2194
1873
|
|
|
@@ -2197,24 +1876,21 @@ Parses a value into a JsonArray, throwing if it does not conform.
|
|
|
2197
1876
|
## Call Signature
|
|
2198
1877
|
|
|
2199
1878
|
```ts
|
|
2200
|
-
<T>(value, assert): T & unknown[];
|
|
1879
|
+
<T>(value: T, assert: ZodFactoryConfig): T & unknown[];
|
|
2201
1880
|
```
|
|
2202
1881
|
|
|
2203
1882
|
### Type Parameters
|
|
2204
1883
|
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
`T`
|
|
1884
|
+
| Type Parameter |
|
|
1885
|
+
| ------ |
|
|
1886
|
+
| `T` |
|
|
2208
1887
|
|
|
2209
1888
|
### Parameters
|
|
2210
1889
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
`T`
|
|
2214
|
-
|
|
2215
|
-
### assert
|
|
2216
|
-
|
|
2217
|
-
`ZodFactoryConfig`
|
|
1890
|
+
| Parameter | Type |
|
|
1891
|
+
| ------ | ------ |
|
|
1892
|
+
| `value` | `T` |
|
|
1893
|
+
| `assert` | `ZodFactoryConfig` |
|
|
2218
1894
|
|
|
2219
1895
|
### Returns
|
|
2220
1896
|
|
|
@@ -2228,8 +1904,8 @@ Parses a value into a JsonArray, throwing if it does not conform.
|
|
|
2228
1904
|
|
|
2229
1905
|
```ts
|
|
2230
1906
|
const toJsonObject: {
|
|
2231
|
-
<T> (value): T & Record<string, unknown> | undefined;
|
|
2232
|
-
<T> (value, assert): T & Record<string, unknown>;
|
|
1907
|
+
<T> (value: T): T & Record<string, unknown> | undefined;
|
|
1908
|
+
<T> (value: T, assert: ZodFactoryConfig): T & Record<string, unknown>;
|
|
2233
1909
|
};
|
|
2234
1910
|
```
|
|
2235
1911
|
|
|
@@ -2238,20 +1914,20 @@ Parses a value into a JsonObject, throwing if it does not conform.
|
|
|
2238
1914
|
## Call Signature
|
|
2239
1915
|
|
|
2240
1916
|
```ts
|
|
2241
|
-
<T>(value): T & Record<string, unknown> | undefined;
|
|
1917
|
+
<T>(value: T): T & Record<string, unknown> | undefined;
|
|
2242
1918
|
```
|
|
2243
1919
|
|
|
2244
1920
|
### Type Parameters
|
|
2245
1921
|
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
`T`
|
|
1922
|
+
| Type Parameter |
|
|
1923
|
+
| ------ |
|
|
1924
|
+
| `T` |
|
|
2249
1925
|
|
|
2250
1926
|
### Parameters
|
|
2251
1927
|
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
`T`
|
|
1928
|
+
| Parameter | Type |
|
|
1929
|
+
| ------ | ------ |
|
|
1930
|
+
| `value` | `T` |
|
|
2255
1931
|
|
|
2256
1932
|
### Returns
|
|
2257
1933
|
|
|
@@ -2260,24 +1936,21 @@ Parses a value into a JsonObject, throwing if it does not conform.
|
|
|
2260
1936
|
## Call Signature
|
|
2261
1937
|
|
|
2262
1938
|
```ts
|
|
2263
|
-
<T>(value, assert): T & Record<string, unknown>;
|
|
1939
|
+
<T>(value: T, assert: ZodFactoryConfig): T & Record<string, unknown>;
|
|
2264
1940
|
```
|
|
2265
1941
|
|
|
2266
1942
|
### Type Parameters
|
|
2267
1943
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
`T`
|
|
1944
|
+
| Type Parameter |
|
|
1945
|
+
| ------ |
|
|
1946
|
+
| `T` |
|
|
2271
1947
|
|
|
2272
1948
|
### Parameters
|
|
2273
1949
|
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
`T`
|
|
2277
|
-
|
|
2278
|
-
### assert
|
|
2279
|
-
|
|
2280
|
-
`ZodFactoryConfig`
|
|
1950
|
+
| Parameter | Type |
|
|
1951
|
+
| ------ | ------ |
|
|
1952
|
+
| `value` | `T` |
|
|
1953
|
+
| `assert` | `ZodFactoryConfig` |
|
|
2281
1954
|
|
|
2282
1955
|
### Returns
|
|
2283
1956
|
|
|
@@ -2291,8 +1964,8 @@ Parses a value into a JsonObject, throwing if it does not conform.
|
|
|
2291
1964
|
|
|
2292
1965
|
```ts
|
|
2293
1966
|
const toJsonValue: {
|
|
2294
|
-
<T> (value): T | undefined;
|
|
2295
|
-
<T> (value, assert): T;
|
|
1967
|
+
<T> (value: T): T | undefined;
|
|
1968
|
+
<T> (value: T, assert: ZodFactoryConfig): T;
|
|
2296
1969
|
};
|
|
2297
1970
|
```
|
|
2298
1971
|
|
|
@@ -2301,20 +1974,20 @@ Parses a value into a JsonValue, throwing if it does not conform.
|
|
|
2301
1974
|
## Call Signature
|
|
2302
1975
|
|
|
2303
1976
|
```ts
|
|
2304
|
-
<T>(value): T | undefined;
|
|
1977
|
+
<T>(value: T): T | undefined;
|
|
2305
1978
|
```
|
|
2306
1979
|
|
|
2307
1980
|
### Type Parameters
|
|
2308
1981
|
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
`T`
|
|
1982
|
+
| Type Parameter |
|
|
1983
|
+
| ------ |
|
|
1984
|
+
| `T` |
|
|
2312
1985
|
|
|
2313
1986
|
### Parameters
|
|
2314
1987
|
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
`T`
|
|
1988
|
+
| Parameter | Type |
|
|
1989
|
+
| ------ | ------ |
|
|
1990
|
+
| `value` | `T` |
|
|
2318
1991
|
|
|
2319
1992
|
### Returns
|
|
2320
1993
|
|
|
@@ -2323,24 +1996,21 @@ Parses a value into a JsonValue, throwing if it does not conform.
|
|
|
2323
1996
|
## Call Signature
|
|
2324
1997
|
|
|
2325
1998
|
```ts
|
|
2326
|
-
<T>(value, assert): T;
|
|
1999
|
+
<T>(value: T, assert: ZodFactoryConfig): T;
|
|
2327
2000
|
```
|
|
2328
2001
|
|
|
2329
2002
|
### Type Parameters
|
|
2330
2003
|
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
`T`
|
|
2004
|
+
| Type Parameter |
|
|
2005
|
+
| ------ |
|
|
2006
|
+
| `T` |
|
|
2334
2007
|
|
|
2335
2008
|
### Parameters
|
|
2336
2009
|
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
`T`
|
|
2340
|
-
|
|
2341
|
-
### assert
|
|
2342
|
-
|
|
2343
|
-
`ZodFactoryConfig`
|
|
2010
|
+
| Parameter | Type |
|
|
2011
|
+
| ------ | ------ |
|
|
2012
|
+
| `value` | `T` |
|
|
2013
|
+
| `assert` | `ZodFactoryConfig` |
|
|
2344
2014
|
|
|
2345
2015
|
### Returns
|
|
2346
2016
|
|