@fgv/ts-utils 4.1.0 → 4.2.1
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.json +30 -0
- package/CHANGELOG.md +17 -1
- package/dist/ts-utils.d.ts +599 -54
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -1
- package/lib/index.js.map +1 -1
- package/lib/packlets/collections/common.d.ts +6 -0
- package/lib/packlets/collections/common.d.ts.map +1 -0
- package/lib/packlets/collections/common.js +24 -0
- package/lib/packlets/collections/common.js.map +1 -0
- package/lib/packlets/collections/index.d.ts +8 -0
- package/lib/packlets/collections/index.d.ts.map +1 -0
- package/lib/packlets/collections/index.js +68 -0
- package/lib/packlets/collections/index.js.map +1 -0
- package/lib/packlets/collections/readonlyResultMap.d.ts +58 -0
- package/lib/packlets/collections/readonlyResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/readonlyResultMap.js +24 -0
- package/lib/packlets/collections/readonlyResultMap.js.map +1 -0
- package/lib/packlets/collections/resultMap.d.ts +180 -0
- package/lib/packlets/collections/resultMap.d.ts.map +1 -0
- package/lib/packlets/collections/resultMap.js +224 -0
- package/lib/packlets/collections/resultMap.js.map +1 -0
- package/lib/packlets/collections/resultMapValidator.d.ts +94 -0
- package/lib/packlets/collections/resultMapValidator.d.ts.map +1 -0
- package/lib/packlets/collections/resultMapValidator.js +126 -0
- package/lib/packlets/collections/resultMapValidator.js.map +1 -0
- package/lib/packlets/collections/utils.d.ts +69 -0
- package/lib/packlets/collections/utils.d.ts.map +1 -0
- package/lib/packlets/collections/utils.js +116 -0
- package/lib/packlets/collections/utils.js.map +1 -0
- package/lib/packlets/collections/validatingResultMap.d.ts +73 -0
- package/lib/packlets/collections/validatingResultMap.d.ts.map +1 -0
- package/lib/packlets/collections/validatingResultMap.js +102 -0
- package/lib/packlets/collections/validatingResultMap.js.map +1 -0
- package/lib/packlets/conversion/baseConverter.d.ts +7 -3
- package/lib/packlets/conversion/baseConverter.d.ts.map +1 -1
- package/lib/packlets/conversion/baseConverter.js +10 -0
- package/lib/packlets/conversion/baseConverter.js.map +1 -1
- package/lib/packlets/conversion/converter.d.ts +19 -3
- package/lib/packlets/conversion/converter.d.ts.map +1 -1
- package/lib/packlets/conversion/converter.js.map +1 -1
- package/lib/packlets/conversion/converters.d.ts +42 -42
- package/lib/packlets/conversion/converters.d.ts.map +1 -1
- package/lib/packlets/conversion/converters.js +9 -9
- package/lib/packlets/conversion/converters.js.map +1 -1
- package/lib/packlets/conversion/defaultingConverter.d.ts +6 -2
- package/lib/packlets/conversion/defaultingConverter.d.ts.map +1 -1
- package/lib/packlets/conversion/defaultingConverter.js +7 -0
- package/lib/packlets/conversion/defaultingConverter.js.map +1 -1
- package/lib/packlets/conversion/objectConverter.d.ts +3 -3
- package/lib/packlets/conversion/objectConverter.d.ts.map +1 -1
- package/lib/packlets/conversion/objectConverter.js.map +1 -1
- package/lib/packlets/validation/field.d.ts +1 -1
- package/lib/packlets/validation/field.d.ts.map +1 -1
- package/lib/packlets/validation/field.js.map +1 -1
- package/lib/packlets/validation/genericValidator.d.ts +6 -2
- package/lib/packlets/validation/genericValidator.d.ts.map +1 -1
- package/lib/packlets/validation/genericValidator.js +19 -2
- package/lib/packlets/validation/genericValidator.js.map +1 -1
- package/lib/packlets/validation/validator.d.ts +18 -1
- package/lib/packlets/validation/validator.d.ts.map +1 -1
- package/lib/packlets/validation/validator.js.map +1 -1
- package/lib/packlets/validation/validatorBase.d.ts +1 -1
- package/lib/packlets/validation/validatorBase.d.ts.map +1 -1
- package/lib/packlets/validation/validatorBase.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ export declare function enumeratedValue<T>(values: T[]): Converter<T, T[]>;
|
|
|
38
38
|
* @returns A {@link Converter | Converter} which applies the mapping and yields `<T>` on success.
|
|
39
39
|
* @public
|
|
40
40
|
*/
|
|
41
|
-
export declare function mappedEnumeratedValue<T>(map: [T, unknown[]][], message?: string): Converter<T,
|
|
41
|
+
export declare function mappedEnumeratedValue<T, TC = unknown>(map: [T, unknown[]][], message?: string): Converter<T, TC>;
|
|
42
42
|
/**
|
|
43
43
|
* Helper function to create a {@link Converter | Converter} which converts `unknown` to some supplied literal value. Succeeds with
|
|
44
44
|
* the supplied value if an identity comparison succeeds, fails otherwise.
|
|
@@ -46,7 +46,7 @@ export declare function mappedEnumeratedValue<T>(map: [T, unknown[]][], message?
|
|
|
46
46
|
* @returns A {@link Converter | Converter} which returns the supplied value on success.
|
|
47
47
|
* @public
|
|
48
48
|
*/
|
|
49
|
-
export declare function literal<T>(value: T): Converter<T,
|
|
49
|
+
export declare function literal<T, TC = unknown>(value: T): Converter<T, TC>;
|
|
50
50
|
/**
|
|
51
51
|
* Deprecated alias for @see literal
|
|
52
52
|
* @param value - The value to be compared.
|
|
@@ -60,7 +60,7 @@ export declare const value: typeof literal;
|
|
|
60
60
|
* Numbers and strings with a numeric format succeed. Anything else fails.
|
|
61
61
|
* @public
|
|
62
62
|
*/
|
|
63
|
-
export declare const number: Converter<number,
|
|
63
|
+
export declare const number: Converter<number, unknown>;
|
|
64
64
|
/**
|
|
65
65
|
* A {@link Converter | Converter} which converts `unknown` to `boolean`.
|
|
66
66
|
* @remarks
|
|
@@ -68,7 +68,7 @@ export declare const number: Converter<number, undefined>;
|
|
|
68
68
|
* Anything else fails.
|
|
69
69
|
* @public
|
|
70
70
|
*/
|
|
71
|
-
export declare const boolean: Converter<boolean,
|
|
71
|
+
export declare const boolean: Converter<boolean, unknown>;
|
|
72
72
|
/**
|
|
73
73
|
* A {@link Converter | Converter} which converts an optional `string` value. Values of type
|
|
74
74
|
* `string` are returned. Anything else returns {@link Success | Success} with value `undefined`.
|
|
@@ -108,7 +108,7 @@ export declare function isA<T, TC = unknown>(description: string, guard: TypeGua
|
|
|
108
108
|
* Anything else returns {@link Success | Success} with value `undefined`.
|
|
109
109
|
* @public
|
|
110
110
|
*/
|
|
111
|
-
export declare const optionalNumber: Converter<number | undefined>;
|
|
111
|
+
export declare const optionalNumber: Converter<number | undefined, unknown>;
|
|
112
112
|
/**
|
|
113
113
|
* A {@link Converter | Converter} to convert an optional `boolean` value.
|
|
114
114
|
* @remarks
|
|
@@ -117,7 +117,7 @@ export declare const optionalNumber: Converter<number | undefined>;
|
|
|
117
117
|
* with value `undefined`.
|
|
118
118
|
* @public
|
|
119
119
|
*/
|
|
120
|
-
export declare const optionalBoolean: Converter<boolean | undefined>;
|
|
120
|
+
export declare const optionalBoolean: Converter<boolean | undefined, unknown>;
|
|
121
121
|
/**
|
|
122
122
|
* A helper function to create a {@link Converter | Converter} for polymorphic values.
|
|
123
123
|
* Returns a converter which invokes the wrapped converters in sequence, returning the
|
|
@@ -148,7 +148,7 @@ export declare function oneOf<T, TC = unknown>(converters: Array<Converter<T, TC
|
|
|
148
148
|
* @returns A {@link Converter | Converter} which returns an array of `<T>`.
|
|
149
149
|
* @public
|
|
150
150
|
*/
|
|
151
|
-
export declare function arrayOf<T, TC =
|
|
151
|
+
export declare function arrayOf<T, TC = unknown>(converter: Converter<T, TC> | Validator<T, TC>, onError?: OnError): Converter<T[], TC>;
|
|
152
152
|
/**
|
|
153
153
|
* {@link Converter | Converter} to convert an `unknown` to an array of `string`.
|
|
154
154
|
* @remarks
|
|
@@ -156,7 +156,7 @@ export declare function arrayOf<T, TC = undefined>(converter: Converter<T, TC> |
|
|
|
156
156
|
* of strings, returns {@link Failure | Failure} with an error message otherwise.
|
|
157
157
|
* @public
|
|
158
158
|
*/
|
|
159
|
-
export declare const stringArray: Converter<string[]>;
|
|
159
|
+
export declare const stringArray: Converter<string[], unknown>;
|
|
160
160
|
/**
|
|
161
161
|
* {@link Converter | Converter} to convert an `unknown` to an array of `number`.
|
|
162
162
|
* @remarks
|
|
@@ -164,14 +164,14 @@ export declare const stringArray: Converter<string[]>;
|
|
|
164
164
|
* of numbers, returns {@link Failure | Failure} with an error message otherwise.
|
|
165
165
|
* @public
|
|
166
166
|
*/
|
|
167
|
-
export declare const numberArray: Converter<number[]>;
|
|
167
|
+
export declare const numberArray: Converter<number[], unknown>;
|
|
168
168
|
/**
|
|
169
169
|
* Options for {@link Converters.(recordOf:3) | Converters.recordOf} and
|
|
170
170
|
* {@link Converters.(mapOf:3) | Converters.mapOf}
|
|
171
171
|
* helper functions.
|
|
172
172
|
* @public
|
|
173
173
|
*/
|
|
174
|
-
export interface KeyedConverterOptions<T extends string = string, TC =
|
|
174
|
+
export interface KeyedConverterOptions<T extends string = string, TC = unknown> {
|
|
175
175
|
/**
|
|
176
176
|
* if `onError` is `'fail'` (default), then the entire conversion fails if any key or element
|
|
177
177
|
* cannot be converted. If `onError` is `'ignore'`, failing elements are silently ignored.
|
|
@@ -187,7 +187,7 @@ export interface KeyedConverterOptions<T extends string = string, TC = undefined
|
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* A helper function to create a {@link Converter | Converter} which converts the `string`-keyed
|
|
190
|
-
* properties using a supplied {@link Converter | Converter<T>} or {@link Validator | Validator<T>} to
|
|
190
|
+
* properties using a supplied {@link Converter | Converter<T, TC>} or {@link Validator | Validator<T>} to
|
|
191
191
|
* produce a `Record<string, T>`.
|
|
192
192
|
* @remarks
|
|
193
193
|
* The resulting converter fails conversion if any element cannot be converted.
|
|
@@ -197,10 +197,10 @@ export interface KeyedConverterOptions<T extends string = string, TC = undefined
|
|
|
197
197
|
* {@label WITH_DEFAULT}
|
|
198
198
|
* @public
|
|
199
199
|
*/
|
|
200
|
-
export declare function recordOf<T, TC =
|
|
200
|
+
export declare function recordOf<T, TC = unknown, TK extends string = string>(converter: Converter<T, TC> | Validator<T, TC>): Converter<Record<TK, T>, TC>;
|
|
201
201
|
/**
|
|
202
202
|
* A helper function to create a {@link Converter | Converter} which converts the `string`-keyed properties
|
|
203
|
-
* using a supplied {@link Converter | Converter<T>} or {@link Validator | Validator<T>} to produce a
|
|
203
|
+
* using a supplied {@link Converter | Converter<T, TC>} or {@link Validator | Validator<T>} to produce a
|
|
204
204
|
* `Record<string, T>` and optionally specified handling of elements that cannot be converted.
|
|
205
205
|
* @remarks
|
|
206
206
|
* if `onError` is `'fail'` (default), then the entire conversion fails if any key or element
|
|
@@ -211,10 +211,10 @@ export declare function recordOf<T, TC = undefined, TK extends string = string>(
|
|
|
211
211
|
* {@label WITH_ON_ERROR}
|
|
212
212
|
* @public
|
|
213
213
|
*/
|
|
214
|
-
export declare function recordOf<T, TC =
|
|
214
|
+
export declare function recordOf<T, TC = unknown, TK extends string = string>(converter: Converter<T, TC> | Validator<T, TC>, onError: 'fail' | 'ignore'): Converter<Record<TK, T>, TC>;
|
|
215
215
|
/**
|
|
216
216
|
* A helper function to create a {@link Converter | Converter} or which converts the `string`-keyed properties
|
|
217
|
-
* using a supplied {@link Converter | Converter<T>} or {@link Validator | Validator<T>} to produce a
|
|
217
|
+
* using a supplied {@link Converter | Converter<T, TC>} or {@link Validator | Validator<T>} to produce a
|
|
218
218
|
* `Record<TK, T>`.
|
|
219
219
|
* @remarks
|
|
220
220
|
* If present, the supplied {@link Converters.KeyedConverterOptions | options} can provide a strongly-typed
|
|
@@ -226,10 +226,10 @@ export declare function recordOf<T, TC = undefined, TK extends string = string>(
|
|
|
226
226
|
* {@label WITH_OPTIONS}
|
|
227
227
|
* @public
|
|
228
228
|
*/
|
|
229
|
-
export declare function recordOf<T, TC =
|
|
229
|
+
export declare function recordOf<T, TC = unknown, TK extends string = string>(converter: Converter<T, TC> | Validator<T, TC>, options: KeyedConverterOptions<TK, TC>): Converter<Record<TK, T>, TC>;
|
|
230
230
|
/**
|
|
231
231
|
* A helper function to create a {@link Converter | Converter} which converts the `string`-keyed properties
|
|
232
|
-
* using a supplied {@link Converter | Converter<T>} or {@link Validator | Validator<T>} to produce a
|
|
232
|
+
* using a supplied {@link Converter | Converter<T, TC>} or {@link Validator | Validator<T>} to produce a
|
|
233
233
|
* `Map<string, T>`.
|
|
234
234
|
* @remarks
|
|
235
235
|
* The resulting converter fails conversion if any element cannot be converted.
|
|
@@ -239,10 +239,10 @@ export declare function recordOf<T, TC = undefined, TK extends string = string>(
|
|
|
239
239
|
* {@label WITH_DEFAULT}
|
|
240
240
|
* @public
|
|
241
241
|
*/
|
|
242
|
-
export declare function mapOf<T, TC =
|
|
242
|
+
export declare function mapOf<T, TC = unknown, TK extends string = string>(converter: Converter<T, TC> | Validator<T, TC>): Converter<Map<TK, T>, TC>;
|
|
243
243
|
/**
|
|
244
244
|
* A helper function to create a {@link Converter | Converter} which converts the `string`-keyed properties
|
|
245
|
-
* using a supplied {@link Converter | Converter<T>} or {@link Validator | Validator<T>} to produce a
|
|
245
|
+
* using a supplied {@link Converter | Converter<T, TC>} or {@link Validator | Validator<T>} to produce a
|
|
246
246
|
* `Map<string, T>` and specified handling of elements that cannot be converted.
|
|
247
247
|
* @remarks
|
|
248
248
|
* if `onError` is `'fail'` (default), then the entire conversion fails if any key or element
|
|
@@ -253,10 +253,10 @@ export declare function mapOf<T, TC = undefined, TK extends string = string>(con
|
|
|
253
253
|
* {@label WITH_ON_ERROR}
|
|
254
254
|
* @public
|
|
255
255
|
*/
|
|
256
|
-
export declare function mapOf<T, TC =
|
|
256
|
+
export declare function mapOf<T, TC = unknown, TK extends string = string>(converter: Converter<T, TC> | Validator<T, TC>, onError: 'fail' | 'ignore'): Converter<Map<TK, T>, TC>;
|
|
257
257
|
/**
|
|
258
258
|
* A helper function to create a {@link Converter | Converter} which converts the `string`-keyed properties
|
|
259
|
-
* using a supplied {@link Converter | Converter<T>} or {@link Validator | Validator<T>} to produce
|
|
259
|
+
* using a supplied {@link Converter | Converter<T, TC>} or {@link Validator | Validator<T>} to produce
|
|
260
260
|
* a `Map<TK,T>`.
|
|
261
261
|
* @remarks
|
|
262
262
|
* If present, the supplied {@link Converters.KeyedConverterOptions | options} can provide a strongly-typed
|
|
@@ -269,7 +269,7 @@ export declare function mapOf<T, TC = undefined, TK extends string = string>(con
|
|
|
269
269
|
* {@label WITH_OPTIONS}
|
|
270
270
|
* @public
|
|
271
271
|
*/
|
|
272
|
-
export declare function mapOf<T, TC =
|
|
272
|
+
export declare function mapOf<T, TC = unknown, TK extends string = string>(converter: Converter<T, TC> | Validator<T, TC>, options: KeyedConverterOptions<TK, TC>): Converter<Map<TK, T>, TC>;
|
|
273
273
|
/**
|
|
274
274
|
* Helper function to create a {@link Converter | Converter} which validates that a supplied value is
|
|
275
275
|
* of a type validated by a supplied validator function and returns it.
|
|
@@ -279,10 +279,10 @@ export declare function mapOf<T, TC = undefined, TK extends string = string>(con
|
|
|
279
279
|
* information otherwise.
|
|
280
280
|
* @param validator - A validator function to determine if the converted value is valid.
|
|
281
281
|
* @param description - A description of the validated type for use in error messages.
|
|
282
|
-
* @returns A new {@link Converter | Converter<T>} which applies the supplied validation.
|
|
282
|
+
* @returns A new {@link Converter | Converter<T, TC>} which applies the supplied validation.
|
|
283
283
|
* @public
|
|
284
284
|
*/
|
|
285
|
-
export declare function validateWith<T, TC =
|
|
285
|
+
export declare function validateWith<T, TC = unknown>(validator: (from: unknown) => from is T, description?: string): Converter<T, TC>;
|
|
286
286
|
/**
|
|
287
287
|
* A helper function to create a {@link Converter | Converter} which extracts and converts an element from an array.
|
|
288
288
|
* @remarks
|
|
@@ -290,10 +290,10 @@ export declare function validateWith<T, TC = undefined>(validator: (from: unknow
|
|
|
290
290
|
* in the supplied array and can be converted. Returns {@link Failure | Failure} with an error message otherwise.
|
|
291
291
|
* @param index - The index of the element to be extracted.
|
|
292
292
|
* @param converter - A {@link Converter | Converter} or {@link Validator | Validator} for the extracted element.
|
|
293
|
-
* @returns A {@link Converter | Converter<T>} which extracts the specified element from an array.
|
|
293
|
+
* @returns A {@link Converter | Converter<T, TC>} which extracts the specified element from an array.
|
|
294
294
|
* @public
|
|
295
295
|
*/
|
|
296
|
-
export declare function element<T, TC =
|
|
296
|
+
export declare function element<T, TC = unknown>(index: number, converter: Converter<T, TC> | Validator<T, TC>): Converter<T, TC>;
|
|
297
297
|
/**
|
|
298
298
|
* A helper function to create a {@link Converter | Converter} which extracts and converts an optional element from an array.
|
|
299
299
|
* @remarks
|
|
@@ -303,10 +303,10 @@ export declare function element<T, TC = undefined>(index: number, converter: Con
|
|
|
303
303
|
* is not an array, if the requested index is negative, or if the element cannot be converted.
|
|
304
304
|
* @param index - The index of the element to be extracted.
|
|
305
305
|
* @param converter - A {@link Converter | Converter} or {@link Validator | Validator} used for the extracted element.
|
|
306
|
-
* @returns A {@link Converter | Converter<T>} which extracts the specified element from an array.
|
|
306
|
+
* @returns A {@link Converter | Converter<T, TC>} which extracts the specified element from an array.
|
|
307
307
|
* @public
|
|
308
308
|
*/
|
|
309
|
-
export declare function optionalElement<T, TC =
|
|
309
|
+
export declare function optionalElement<T, TC = unknown>(index: number, converter: Converter<T, TC> | Validator<T, TC>): Converter<T | undefined, TC>;
|
|
310
310
|
/**
|
|
311
311
|
* A helper function to create a {@link Converter | Converter} which extracts and convert a property specified
|
|
312
312
|
* by name from an object.
|
|
@@ -319,7 +319,7 @@ export declare function optionalElement<T, TC = undefined>(index: number, conver
|
|
|
319
319
|
* field.
|
|
320
320
|
* @public
|
|
321
321
|
*/
|
|
322
|
-
export declare function field<T, TC =
|
|
322
|
+
export declare function field<T, TC = unknown>(name: string, converter: Converter<T, TC> | Validator<T, TC>): Converter<T, TC>;
|
|
323
323
|
/**
|
|
324
324
|
* A helper function to create a {@link Converter | Converter} which extracts and convert a property specified
|
|
325
325
|
* by name from an object.
|
|
@@ -332,10 +332,10 @@ export declare function field<T, TC = undefined>(name: string, converter: Conver
|
|
|
332
332
|
* @param converter - {@link Converter | Converter} or {@link Validator | Validator} to use for the extracted field.
|
|
333
333
|
* @public
|
|
334
334
|
*/
|
|
335
|
-
export declare function optionalField<T, TC =
|
|
335
|
+
export declare function optionalField<T, TC = unknown>(name: string, converter: Converter<T, TC> | Validator<T, TC>): Converter<T | undefined, TC>;
|
|
336
336
|
/**
|
|
337
|
-
* Helper function to create a {@link Conversion.ObjectConverter | ObjectConverter<T>} which converts an object
|
|
338
|
-
* without changing shape, given a {@link Conversion.FieldConverters | FieldConverters<T>} and an optional
|
|
337
|
+
* Helper function to create a {@link Conversion.ObjectConverter | ObjectConverter<T, TC>} which converts an object
|
|
338
|
+
* without changing shape, given a {@link Conversion.FieldConverters | FieldConverters<T, TC>} and an optional
|
|
339
339
|
* {@link Conversion.ObjectConverterOptions | ObjectConverterOptions<T>} to further refine conversion behavior.
|
|
340
340
|
* @remarks
|
|
341
341
|
* By default, if all of the requested fields exist and can be converted, returns {@link Success | Success}
|
|
@@ -345,7 +345,7 @@ export declare function optionalField<T, TC = undefined>(name: string, converter
|
|
|
345
345
|
*
|
|
346
346
|
* Fields that succeed but convert to undefined are omitted from the result object but do not
|
|
347
347
|
* fail the conversion.
|
|
348
|
-
* @param properties - An {@link Conversion.FieldConverters | FieldConverters<T>} defining the shape of the
|
|
348
|
+
* @param properties - An {@link Conversion.FieldConverters | FieldConverters<T, TC>} defining the shape of the
|
|
349
349
|
* source object and {@link Converter | converters} to be applied to each properties.
|
|
350
350
|
* @param options - An {@link Conversion.ObjectConverterOptions | ObjectConverterOptions<T>} containing options
|
|
351
351
|
* for the object converter.
|
|
@@ -353,10 +353,10 @@ export declare function optionalField<T, TC = undefined>(name: string, converter
|
|
|
353
353
|
* {@label WITH_OPTIONS}
|
|
354
354
|
* @public
|
|
355
355
|
*/
|
|
356
|
-
export declare function object<T>(properties: FieldConverters<T>, options?: ObjectConverterOptions<T>): ObjectConverter<T>;
|
|
356
|
+
export declare function object<T, TC = unknown>(properties: FieldConverters<T, TC>, options?: ObjectConverterOptions<T>): ObjectConverter<T, TC>;
|
|
357
357
|
/**
|
|
358
|
-
* Helper function to create a {@link Conversion.ObjectConverter | ObjectConverter<T>} which converts an object
|
|
359
|
-
* without changing shape, given a {@link Conversion.FieldConverters | FieldConverters<T>} and a set of
|
|
358
|
+
* Helper function to create a {@link Conversion.ObjectConverter | ObjectConverter<T, TC>} which converts an object
|
|
359
|
+
* without changing shape, given a {@link Conversion.FieldConverters | FieldConverters<T, TC>} and a set of
|
|
360
360
|
* optional properties.
|
|
361
361
|
* @remarks
|
|
362
362
|
* By default, if all of the requested fields exist and can be converted, returns {@link Success | Success}
|
|
@@ -366,7 +366,7 @@ export declare function object<T>(properties: FieldConverters<T>, options?: Obje
|
|
|
366
366
|
*
|
|
367
367
|
* Fields that succeed but convert to undefined are omitted from the result object but do not
|
|
368
368
|
* fail the conversion.
|
|
369
|
-
* @param properties - An {@link Conversion.FieldConverters | FieldConverters<T>} defining the shape of the
|
|
369
|
+
* @param properties - An {@link Conversion.FieldConverters | FieldConverters<T, TC>} defining the shape of the
|
|
370
370
|
* source object and {@link Converter | converters} to be applied to each properties.
|
|
371
371
|
* @param optional - An array of `(keyof T)` listing the keys to be considered optional.
|
|
372
372
|
* {@label WITH_KEYS}
|
|
@@ -374,7 +374,7 @@ export declare function object<T>(properties: FieldConverters<T>, options?: Obje
|
|
|
374
374
|
* @public
|
|
375
375
|
* @deprecated Use {@link Converters.(object:1) | Converters.object(fields, options)} instead.
|
|
376
376
|
*/
|
|
377
|
-
export declare function object<T>(properties: FieldConverters<T>, optional: (keyof T)[]): ObjectConverter<T>;
|
|
377
|
+
export declare function object<T, TC = unknown>(properties: FieldConverters<T, TC>, optional: (keyof T)[]): ObjectConverter<T, TC>;
|
|
378
378
|
/**
|
|
379
379
|
* Options for the {@link Converters.(strictObject:1)} helper function.
|
|
380
380
|
* @public
|
|
@@ -382,7 +382,7 @@ export declare function object<T>(properties: FieldConverters<T>, optional: (key
|
|
|
382
382
|
export type StrictObjectConverterOptions<T> = Omit<ObjectConverterOptions<T>, 'strict'>;
|
|
383
383
|
/**
|
|
384
384
|
* Helper function to create a {@link Conversion.ObjectConverter | ObjectConverter} which converts an object
|
|
385
|
-
* without changing shape, a {@link Conversion.FieldConverters | FieldConverters<T>} and an optional
|
|
385
|
+
* without changing shape, a {@link Conversion.FieldConverters | FieldConverters<T, TC>} and an optional
|
|
386
386
|
* {@link Converters.StrictObjectConverterOptions | StrictObjectConverterOptions<T>} to further refine
|
|
387
387
|
* conversion behavior.
|
|
388
388
|
*
|
|
@@ -398,10 +398,10 @@ export type StrictObjectConverterOptions<T> = Omit<ObjectConverterOptions<T>, 's
|
|
|
398
398
|
* {@label WITH_OPTIONS}
|
|
399
399
|
* @public
|
|
400
400
|
*/
|
|
401
|
-
export declare function strictObject<T>(properties: FieldConverters<T>, options?: StrictObjectConverterOptions<T>): ObjectConverter<T>;
|
|
401
|
+
export declare function strictObject<T, TC = unknown>(properties: FieldConverters<T, TC>, options?: StrictObjectConverterOptions<T>): ObjectConverter<T, TC>;
|
|
402
402
|
/**
|
|
403
403
|
* Helper function to create a {@link Conversion.ObjectConverter | ObjectConverter} which converts an object
|
|
404
|
-
* without changing shape, a {@link Conversion.FieldConverters | FieldConverters<T>} and an optional
|
|
404
|
+
* without changing shape, a {@link Conversion.FieldConverters | FieldConverters<T, TC>} and an optional
|
|
405
405
|
* {@link Converters.StrictObjectConverterOptions | StrictObjectConverterOptions<T>} to further refine
|
|
406
406
|
* conversion behavior.
|
|
407
407
|
*
|
|
@@ -418,7 +418,7 @@ export declare function strictObject<T>(properties: FieldConverters<T>, options?
|
|
|
418
418
|
* @deprecated Use {@link Converters.(strictObject:1) | Converters.strictObject(options)} instead.
|
|
419
419
|
* @public
|
|
420
420
|
*/
|
|
421
|
-
export declare function strictObject<T>(properties: FieldConverters<T>, optional: (keyof T)[]): ObjectConverter<T>;
|
|
421
|
+
export declare function strictObject<T, TC = unknown>(properties: FieldConverters<T, TC>, optional: (keyof T)[]): ObjectConverter<T, TC>;
|
|
422
422
|
/**
|
|
423
423
|
* A string-keyed `Record<string, Converter>` which maps specific {@link Converter | converters} or
|
|
424
424
|
* {@link Validator | Validators} to the value of a discriminator property.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/conversion/converters.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,oBAAoB,EAAE,S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F;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,IAAI;KACxD,GAAG,IAAI,MAAM,KAAK,GAAG;QACpB;;WAEG;QACH,IAAI,EAAE,MAAM,IAAI,CAAC;QACjB;;WAEG;QACH,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACjE;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;CACF,CAAC;AAEF;;;GAGG;AAEH,MAAM,WAAW,sBAAsB,CAAC,IAAI;IAC1C;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAC;IAEb;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EACvD,iBAAiB,EAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,EACrD,OAAO,CAAC,EAAE,sBAAsB,CAAC,IAAI,CAAC,GACrC,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC,CA2CtB"}
|
|
@@ -305,9 +305,9 @@ exports.stringArray = arrayOf(exports.string);
|
|
|
305
305
|
*/
|
|
306
306
|
exports.numberArray = arrayOf(exports.number);
|
|
307
307
|
/**
|
|
308
|
-
* Concrete implementation of {@link Converters.(recordOf:1) | Converters.recordOf(Converter<T>)},
|
|
309
|
-
* {@link Converters.(recordOf:2) | Converters.recordOf(Converter<T>, 'fail' or 'ignore')}, and
|
|
310
|
-
* {@link Converters.(recordOf:3) | Converters.recordOf(Converter<T>, KeyedConverterOptions)}.
|
|
308
|
+
* Concrete implementation of {@link Converters.(recordOf:1) | Converters.recordOf(Converter<T, TC>)},
|
|
309
|
+
* {@link Converters.(recordOf:2) | Converters.recordOf(Converter<T, TC>, 'fail' or 'ignore')}, and
|
|
310
|
+
* {@link Converters.(recordOf:3) | Converters.recordOf(Converter<T, TC>, KeyedConverterOptions)}.
|
|
311
311
|
* @internal
|
|
312
312
|
*/
|
|
313
313
|
function recordOf(converter, option = 'fail') {
|
|
@@ -339,9 +339,9 @@ function recordOf(converter, option = 'fail') {
|
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
|
-
* Concrete implementation of {@link Converters.(mapOf:1) | Converters.mapOf(Converter<T>)},
|
|
343
|
-
* {@link Converters.(mapOf:2) | Converters.mapOf(Converter<T>, 'fail' or 'ignore')}, and
|
|
344
|
-
* {@link Converters.(mapOf:3) | Converters.mapOf(Converter<T>, KeyedConverterOptions)}.
|
|
342
|
+
* Concrete implementation of {@link Converters.(mapOf:1) | Converters.mapOf(Converter<T, TC>)},
|
|
343
|
+
* {@link Converters.(mapOf:2) | Converters.mapOf(Converter<T, TC>, 'fail' or 'ignore')}, and
|
|
344
|
+
* {@link Converters.(mapOf:3) | Converters.mapOf(Converter<T, TC>, KeyedConverterOptions)}.
|
|
345
345
|
* @internal
|
|
346
346
|
*/
|
|
347
347
|
function mapOf(converter, option = 'fail') {
|
|
@@ -381,7 +381,7 @@ function mapOf(converter, option = 'fail') {
|
|
|
381
381
|
* information otherwise.
|
|
382
382
|
* @param validator - A validator function to determine if the converted value is valid.
|
|
383
383
|
* @param description - A description of the validated type for use in error messages.
|
|
384
|
-
* @returns A new {@link Converter | Converter<T>} which applies the supplied validation.
|
|
384
|
+
* @returns A new {@link Converter | Converter<T, TC>} which applies the supplied validation.
|
|
385
385
|
* @public
|
|
386
386
|
*/
|
|
387
387
|
function validateWith(validator, description) {
|
|
@@ -399,7 +399,7 @@ function validateWith(validator, description) {
|
|
|
399
399
|
* in the supplied array and can be converted. Returns {@link Failure | Failure} with an error message otherwise.
|
|
400
400
|
* @param index - The index of the element to be extracted.
|
|
401
401
|
* @param converter - A {@link Converter | Converter} or {@link Validator | Validator} for the extracted element.
|
|
402
|
-
* @returns A {@link Converter | Converter<T>} which extracts the specified element from an array.
|
|
402
|
+
* @returns A {@link Converter | Converter<T, TC>} which extracts the specified element from an array.
|
|
403
403
|
* @public
|
|
404
404
|
*/
|
|
405
405
|
function element(index, converter) {
|
|
@@ -425,7 +425,7 @@ function element(index, converter) {
|
|
|
425
425
|
* is not an array, if the requested index is negative, or if the element cannot be converted.
|
|
426
426
|
* @param index - The index of the element to be extracted.
|
|
427
427
|
* @param converter - A {@link Converter | Converter} or {@link Validator | Validator} used for the extracted element.
|
|
428
|
-
* @returns A {@link Converter | Converter<T>} which extracts the specified element from an array.
|
|
428
|
+
* @returns A {@link Converter | Converter<T, TC>} which extracts the specified element from an array.
|
|
429
429
|
* @public
|
|
430
430
|
*/
|
|
431
431
|
function optionalElement(index, converter) {
|