@fgv/ts-utils 5.1.0-16 → 5.1.0-17

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.
@@ -34,7 +34,7 @@ const base_1 = require("../base");
34
34
  */
35
35
  class Collector {
36
36
  /**
37
- * {@inheritDoc Collections.ResultMap.size}
37
+ * Returns the number of entries in the map.
38
38
  */
39
39
  get size() {
40
40
  return this._byIndex.length;
@@ -90,13 +90,16 @@ class Collector {
90
90
  return (0, base_1.succeedWithDetail)(item, 'added');
91
91
  }
92
92
  /**
93
- * {@inheritDoc Collections.ResultMap.entries}
93
+ * Returns an iterator over the map entries.
94
+ * @returns An iterator over the map entries.
94
95
  */
95
96
  entries() {
96
97
  return this._byKey.entries();
97
98
  }
98
99
  /**
99
- * {@inheritDoc Collections.ResultMap.forEach}
100
+ * Calls a function for each entry in the map.
101
+ * @param callback - The function to call for each entry.
102
+ * @param arg - An optional argument to pass to the callback.
100
103
  */
101
104
  forEach(callback, arg) {
102
105
  for (const [key, value] of this._byKey.entries()) {
@@ -104,14 +107,20 @@ class Collector {
104
107
  }
105
108
  }
106
109
  /**
107
- * {@inheritDoc Collections.ResultMap.get}
110
+ * Gets a value by key.
111
+ * @param key - The key to look up.
112
+ * @returns Returns {@link DetailedSuccess | Success} with the value and detail `exists` if found,
113
+ * or {@link DetailedFailure | Failure} with detail `not-found` if the key does not exist.
108
114
  */
109
115
  get(key) {
110
116
  const item = this._byKey.get(key);
111
117
  return item ? (0, base_1.succeedWithDetail)(item, 'exists') : (0, base_1.failWithDetail)(`${key}: not found`, 'not-found');
112
118
  }
113
119
  /**
114
- * {@inheritDoc Collections.IReadOnlyCollector.getAt}
120
+ * Gets the item at a specified index.
121
+ * @param index - The index of the item to retrieve.
122
+ * @returns Returns {@link Success | Success} with the item if it exists, or {@link Failure | Failure}
123
+ * with an error if the index is out of range.
115
124
  */
116
125
  getAt(index) {
117
126
  if (typeof index !== 'number') {
@@ -149,25 +158,30 @@ class Collector {
149
158
  });
150
159
  }
151
160
  /**
152
- * {@inheritDoc Collections.ResultMap.has}
161
+ * Returns true if the map contains an entry with the given key.
162
+ * @param key - The key to check for.
163
+ * @returns `true` if the key exists, `false` otherwise.
153
164
  */
154
165
  has(key) {
155
166
  return this._byKey.has(key);
156
167
  }
157
168
  /**
158
- * {@inheritDoc Collections.ResultMap.keys}
169
+ * Returns an iterator over the map keys.
170
+ * @returns An iterator over the map keys.
159
171
  */
160
172
  keys() {
161
173
  return this._byKey.keys();
162
174
  }
163
175
  /**
164
- * {@inheritDoc Collections.ResultMap.values}
176
+ * Returns an iterator over the map values.
177
+ * @returns An iterator over the map values.
165
178
  */
166
179
  values() {
167
180
  return this._byKey.values();
168
181
  }
169
182
  /**
170
- * {@inheritDoc Collections.IReadOnlyCollector.valuesByIndex}
183
+ * Gets all items in the collection, ordered by index.
184
+ * @returns An array of items in the collection, ordered by index.
171
185
  */
172
186
  valuesByIndex() {
173
187
  return this._byIndex;
@@ -24,7 +24,14 @@ export interface IReadOnlyCollectorValidator<TITEM extends ICollectible<any, any
24
24
  */
25
25
  has(key: string): boolean;
26
26
  /**
27
- * {@inheritDoc Collections.Collector.getOrAdd}
27
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
28
+ * using a factory callback if no item with that key exists.
29
+ * @param key - The weakly-typed key of the item to get or add.
30
+ * @param factory - The factory callback to create the item.
31
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
32
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
33
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
34
+ * appropriate detail if the item could not be added.
28
35
  */
29
36
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
30
37
  }
@@ -53,7 +60,12 @@ export declare class CollectorValidator<TITEM extends ICollectible<any, any>> im
53
60
  */
54
61
  constructor(params: ICollectorValidatorCreateParams<TITEM>);
55
62
  /**
56
- * {@inheritDoc Collections.Collector.add}
63
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
64
+ * that adding an object that is already in the collection again will succeed without updating the collection.
65
+ * @param item - The item to add.
66
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
67
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
68
+ * an error message and appropriate detail if the item could not be added.
57
69
  */
58
70
  add(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
59
71
  /**
@@ -61,12 +73,24 @@ export declare class CollectorValidator<TITEM extends ICollectible<any, any>> im
61
73
  */
62
74
  get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
63
75
  /**
64
- * {@inheritDoc Collections.Collector.getOrAdd}
76
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
77
+ * using a factory callback if no item with that key exists.
78
+ * @param key - The weakly-typed key of the item to get or add.
79
+ * @param factory - The factory callback to create the item.
80
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
81
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
82
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
83
+ * appropriate detail if the item could not be added.
65
84
  */
66
85
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
67
86
  /**
68
- * {@inheritDoc Collections.Collector.getOrAdd}
69
- * @param item - The item to add to the collector.
87
+ * Gets an existing item with a key matching that of the supplied item, or adds the supplied
88
+ * item to the collector if no item with that key exists.
89
+ * @param item - The weakly-typed item to get or add.
90
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
91
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
92
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
93
+ * appropriate detail if the item could not be added.
70
94
  */
71
95
  getOrAdd(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
72
96
  /**
@@ -40,7 +40,12 @@ class CollectorValidator {
40
40
  this.converters = params.converters;
41
41
  }
42
42
  /**
43
- * {@inheritDoc Collections.Collector.add}
43
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
44
+ * that adding an object that is already in the collection again will succeed without updating the collection.
45
+ * @param item - The item to add.
46
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
47
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
48
+ * an error message and appropriate detail if the item could not be added.
44
49
  */
45
50
  add(item) {
46
51
  return this._convertValue(item).onSuccess((i) => {
@@ -37,7 +37,12 @@ export declare class ConvertingCollector<TITEM extends ICollectible<any, any>, T
37
37
  */
38
38
  static createConvertingCollector<TITEM extends ICollectible<any, any>, TSRC = TITEM>(params: IConvertingCollectorConstructorParams<TITEM, TSRC>): Result<ConvertingCollector<TITEM, TSRC>>;
39
39
  /**
40
- * {@inheritDoc Collections.Collector.add}
40
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
41
+ * that adding an object that is already in the collection again will succeed without updating the collection.
42
+ * @param item - The item to add.
43
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
44
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
45
+ * an error message and appropriate detail if the item could not be added.
41
46
  */
42
47
  add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
43
48
  /**
@@ -60,11 +65,24 @@ export declare class ConvertingCollector<TITEM extends ICollectible<any, any>, T
60
65
  */
61
66
  add(key: CollectibleKey<TITEM>, cb: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
62
67
  /**
63
- * {@inheritDoc Collections.Collector.getOrAdd}
68
+ * Gets an existing item with a key matching that of the supplied item, or adds the supplied
69
+ * item to the collector if no item with that key exists.
70
+ * @param item - The item to get or add.
71
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
72
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
73
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
74
+ * appropriate detail if the item could not be added.
64
75
  */
65
76
  getOrAdd(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
66
77
  /**
67
- * {@inheritDoc Collections.Collector.getOrAdd}
78
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
79
+ * using a factory callback if no item with that key exists.
80
+ * @param key - The key of the item to get or add.
81
+ * @param callback - The factory callback to create the item.
82
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
83
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
84
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
85
+ * appropriate detail if the item could not be added.
68
86
  */
69
87
  getOrAdd(key: CollectibleKey<TITEM>, callback: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
70
88
  /**
@@ -32,7 +32,12 @@ export declare class ConvertingCollectorValidator<TITEM extends ICollectible<any
32
32
  */
33
33
  constructor(params: IConvertingCollectorValidatorCreateParams<TITEM, TSRC>);
34
34
  /**
35
- * {@inheritDoc Collections.ConvertingCollector.add}
35
+ * Adds an item to the collector using the default factory at a specified key,
36
+ * failing if an item with that key already exists.
37
+ * @param key - The weakly-typed key of the item to add.
38
+ * @param value - The source representation of the item to be added.
39
+ * @returns Returns {@link Success | Success} with the item if it is added, or {@link Failure | Failure} with
40
+ * an error if the item cannot be created and indexed.
36
41
  */
37
42
  add(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
38
43
  /**
@@ -45,11 +50,25 @@ export declare class ConvertingCollectorValidator<TITEM extends ICollectible<any
45
50
  */
46
51
  get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
47
52
  /**
48
- * {@inheritDoc Collections.ConvertingCollector.getOrAdd}
53
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
54
+ * by converting the supplied weakly-typed value if no item with that key exists.
55
+ * @param key - The weakly-typed key of the item to get or add.
56
+ * @param value - The weakly-typed source value to convert and add if the key does not exist.
57
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
58
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
59
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
60
+ * appropriate detail if the item could not be added.
49
61
  */
50
62
  getOrAdd(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
51
63
  /**
52
- * {@inheritDoc Collections.Collector.getOrAdd}
64
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
65
+ * using a factory callback if no item with that key exists.
66
+ * @param key - The weakly-typed key of the item to get or add.
67
+ * @param factory - The factory callback to create the item.
68
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
69
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
70
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
71
+ * appropriate detail if the item could not be added.
53
72
  */
54
73
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
55
74
  /**
@@ -18,31 +18,42 @@ export type ResultMapForEachCb<TK extends string = string, TE = unknown> = (valu
18
18
  */
19
19
  export interface IReadOnlyResultMap<TK extends string = string, TV = unknown> {
20
20
  /**
21
- * {@inheritDoc Collections.ResultMap.size}
21
+ * Returns the number of entries in the map.
22
22
  */
23
23
  readonly size: number;
24
24
  /**
25
- * {@inheritDoc Collections.ResultMap.entries}
25
+ * Returns an iterator over the map entries.
26
+ * @returns An iterator over the map entries.
26
27
  */
27
28
  entries(): IterableIterator<KeyValueEntry<TK, TV>>;
28
29
  /**
29
- * {@inheritDoc Collections.ResultMap.forEach}
30
+ * Calls a function for each entry in the map.
31
+ * @param cb - The function to call for each entry.
32
+ * @param arg - An optional argument to pass to the callback.
30
33
  */
31
34
  forEach(cb: ResultMapForEachCb, arg?: unknown): void;
32
35
  /**
33
- * {@inheritDoc Collections.ResultMap.get}
36
+ * Gets a value from the map.
37
+ * @param key - The key to retrieve.
38
+ * @returns `Success` with the value and detail `exists` if the key was found,
39
+ * `Failure` with detail `not-found` if the key was not found or with detail
40
+ * `invalid-key` if the key is invalid.
34
41
  */
35
42
  get(key: TK): DetailedResult<TV, ResultMapResultDetail>;
36
43
  /**
37
- * {@inheritDoc Collections.ResultMap.has}
44
+ * Returns `true` if the map contains a key.
45
+ * @param key - The key to check.
46
+ * @returns `true` if the key exists, `false` otherwise.
38
47
  */
39
48
  has(key: TK): boolean;
40
49
  /**
41
- * {@inheritDoc Collections.ResultMap.keys}
50
+ * Returns an iterator over the map keys.
51
+ * @returns An iterator over the map keys.
42
52
  */
43
53
  keys(): IterableIterator<TK>;
44
54
  /**
45
- * {@inheritDoc Collections.ResultMap.values}
55
+ * Returns an iterator over the map values.
56
+ * @returns An iterator over the map values.
46
57
  */
47
58
  values(): IterableIterator<TV>;
48
59
  /**
@@ -12,15 +12,19 @@ import { CollectorValidator } from './collectorValidator';
12
12
  */
13
13
  export interface IReadOnlyValidatingCollector<TITEM extends ICollectible<any, any>> extends IReadOnlyValidatingResultMap<CollectibleKey<TITEM>, TITEM> {
14
14
  /**
15
- * {@inheritDoc Collections.ValidatingCollector.validating}
15
+ * A {@link Collections.CollectorValidator | CollectorValidator} which validates keys and values
16
+ * before inserting them into this collector.
16
17
  */
17
18
  readonly validating: IReadOnlyCollectorValidator<TITEM>;
18
19
  /**
19
- * {@inheritDoc Collections.IReadOnlyCollector.getAt}
20
+ * Gets the item at a specified index.
21
+ * @param index - The index of the item to retrieve.
22
+ * @returns `Success` with the item if it exists, or `Failure` with an error if the index is out of range.
20
23
  */
21
24
  getAt(index: number): Result<TITEM>;
22
25
  /**
23
- * {@inheritDoc Collections.IReadOnlyCollector.valuesByIndex}
26
+ * Gets all items in the collection, ordered by index.
27
+ * @returns An array of items in the collection, ordered by index.
24
28
  */
25
29
  valuesByIndex(): ReadonlyArray<TITEM>;
26
30
  }
@@ -10,7 +10,8 @@ import { IReadOnlyResultMapValidator, ResultMapValidator } from './resultMapVali
10
10
  */
11
11
  export interface IReadOnlyValidatingResultMap<TK extends string = string, TV = unknown> extends IReadOnlyResultMap<TK, TV> {
12
12
  /**
13
- * {@inheritDoc Collections.ValidatingResultMap.validating}
13
+ * A {@link Collections.ResultMapValidator | ResultMapValidator} which validates keys and values
14
+ * before inserting them into this collection.
14
15
  */
15
16
  readonly validating: IReadOnlyResultMapValidator<TK, TV>;
16
17
  }
@@ -64,63 +64,146 @@ export declare class BaseConverter<T, TC = unknown> implements Converter<T, TC>
64
64
  */
65
65
  constructor(converter: ConverterFunc<T, TC>, defaultContext?: TC, traits?: ConverterTraits);
66
66
  /**
67
- * {@inheritDoc Converter.isOptional}
67
+ * Indicates whether this element is explicitly optional.
68
68
  */
69
69
  get isOptional(): boolean;
70
70
  /**
71
- * {@inheritDoc Converter.brand}
71
+ * Returns the brand for a branded type.
72
72
  */
73
73
  get brand(): string | undefined;
74
74
  /**
75
- * {@inheritDoc Converter.convert}
75
+ * Converts from `unknown` to `<T>`. For objects and arrays, is guaranteed
76
+ * to return a new entity, with any unrecognized properties removed.
77
+ * @param from - The `unknown` to be converted
78
+ * @param context - An optional conversion context of type `<TC>` to be used in
79
+ * the conversion.
80
+ * @returns A {@link Result} with a {@link Success} and a value on success or an
81
+ * {@link Failure} with a a message on failure.
76
82
  */
77
83
  convert(from: unknown, context?: TC): Result<T>;
78
84
  /**
79
- * {@inheritDoc Converter.convertOptional}
85
+ * Converts from `unknown` to `<T>` or `undefined`, as appropriate.
86
+ *
87
+ * @remarks
88
+ * If `onError` is `failOnError`, the converter succeeds for
89
+ * `undefined` or any convertible value, but reports an error
90
+ * if it encounters a value that cannot be converted.
91
+ *
92
+ * If `onError` is `ignoreErrors` (default) then values that
93
+ * cannot be converted result in a successful return of `undefined`.
94
+ * @param from - The `unknown` to be converted
95
+ * @param context - An optional conversion context of type `<TC>` to be used in
96
+ * the conversion.
97
+ * @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
98
+ * @returns A {@link Result} with a {@link Success} and a value on success or an
99
+ * {@link Failure} with a a message on failure.
80
100
  */
81
101
  convertOptional(from: unknown, context?: TC, onError?: OnError): Result<T | undefined>;
82
102
  /**
83
- * {@inheritDoc Converter.optional}
103
+ * Creates a {@link Converter} for an optional value.
104
+ *
105
+ * @remarks
106
+ * If `onError` is `failOnError`, the resulting converter will accept `undefined`
107
+ * or a convertible value, but report an error if it encounters a value that cannot be
108
+ * converted.
109
+ *
110
+ * If `onError` is `ignoreErrors` (default) then values that cannot be converted will
111
+ * result in a successful return of `undefined`.
112
+ *
113
+ * @param onError - Specifies handling of values that cannot be converted (default `ignoreErrors`).
114
+ * @returns A new {@link Converter} returning `<T|undefined>`.
84
115
  */
85
116
  optional(onError?: OnError): Converter<T | undefined, TC>;
86
117
  /**
87
- * {@inheritDoc Converter.map}
118
+ * Creates a {@link Converter} which applies a (possibly) mapping conversion to
119
+ * the converted value of this {@link Converter}.
120
+ * @param mapper - A function which maps from the the result type `<T>` of this
121
+ * converter to a new result type `<T2>`.
122
+ * @returns A new {@link Converter} returning `<T2>`.
88
123
  */
89
124
  map<T2>(mapper: (from: T, context?: TC) => Result<T2>): Converter<T2, TC>;
90
125
  /**
91
- * {@inheritDoc Converter.mapConvert}
126
+ * Creates a {@link Converter} which applies an additional supplied
127
+ * converter to the result of this converter.
128
+ *
129
+ * @param mapConverter - The {@link Converter} to be applied to the
130
+ * converted result from this {@link Converter}.
131
+ * @returns A new {@link Converter} returning `<T2>`.
92
132
  */
93
133
  mapConvert<T2>(mapConverter: Converter<T2>): Converter<T2, TC>;
94
134
  /**
95
- * {@inheritDoc Converter.mapItems}
135
+ * Creates a {@link Converter} which maps the individual items of a collection
136
+ * resulting from this {@link Converter} using the supplied map function.
137
+ *
138
+ * @remarks
139
+ * Fails if `from` is not an array.
140
+ *
141
+ * @param mapper - The map function to be applied to each element of the
142
+ * result of this {@link Converter}.
143
+ * @returns A new {@link Converter} returning `<TI[]>`.
96
144
  */
97
145
  mapItems<TI>(mapper: (from: unknown, context?: TC) => Result<TI>): Converter<TI[], TC>;
98
146
  /**
99
- * {@inheritDoc Converter.mapConvertItems}
147
+ * Creates a {@link Converter} which maps the individual items of a collection
148
+ * resulting from this {@link Converter} using the supplied {@link Converter}.
149
+ *
150
+ * @remarks
151
+ * Fails if `from` is not an array.
152
+ *
153
+ * @param mapConverter - The {@link Converter} to be applied to each element of the
154
+ * result of this {@link Converter}.
155
+ * @returns A new {@link Converter} returning `<TI[]>`.
100
156
  */
101
157
  mapConvertItems<TI>(mapConverter: Converter<TI, unknown>): Converter<TI[], TC>;
102
158
  /**
103
- * {@inheritDoc Converter.withAction}
159
+ * Creates a {@link Converter | Converter} which applies a supplied action after
160
+ * conversion. The supplied action is always called regardless of success or failure
161
+ * of the base conversion and is allowed to mutate the return type.
162
+ * @param action - The action to be applied.
104
163
  */
105
164
  withAction<TI>(action: (result: Result<T>, context?: TC) => Result<TI>): Converter<TI, TC>;
106
165
  /**
107
- * {@inheritDoc Converter.withTypeGuard}
166
+ * Creates a {@link Converter} which applies a supplied type guard to the conversion
167
+ * result.
168
+ * @param guard - The type guard function to apply.
169
+ * @param message - Optional message to be reported if the type guard fails.
170
+ * @returns A new {@link Converter} returning `<TI>`.
108
171
  */
109
172
  withTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI, TC>;
110
173
  /**
111
- * {@inheritDoc Converter.withItemTypeGuard}
174
+ * Creates a {@link Converter} which applies a supplied type guard to each member of
175
+ * the conversion result from this converter.
176
+ *
177
+ * @remarks
178
+ * Fails if the conversion result is not an array or if any member fails the
179
+ * type guard.
180
+ * @param guard - The type guard function to apply to each element.
181
+ * @param message - Optional message to be reported if the type guard fails.
182
+ * @returns A new {@link Converter} returning `<TI>`.
112
183
  */
113
184
  withItemTypeGuard<TI>(guard: (from: unknown, context?: TC) => from is TI, message?: string): Converter<TI[], TC>;
114
185
  /**
115
- * {@inheritDoc Converter.withConstraint}
186
+ * Creates a {@link Converter} which applies an optional constraint to the result
187
+ * of this conversion. If this {@link Converter} (the base converter) succeeds, the new
188
+ * converter calls a supplied constraint evaluation function with the conversion, which
189
+ * fails the entire conversion if the constraint function returns either `false` or
190
+ * {@link Failure | Failure<T>}.
191
+ *
192
+ * @param constraint - Constraint evaluation function.
193
+ * @param options - {@link Conversion.ConstraintOptions | Options} for constraint evaluation.
194
+ * @returns A new {@link Converter} returning `<T>`.
116
195
  */
117
196
  withConstraint(constraint: (val: T, context?: TC) => boolean | Result<T>, options?: ConstraintOptions): Converter<T, TC>;
118
197
  /**
119
- * {@inheritDoc Converter.withBrand}
198
+ * Returns a converter which adds a brand to the type to prevent mismatched usage
199
+ * of simple types.
200
+ * @param brand - The brand to be applied to the result value.
201
+ * @returns A {@link Converter} returning `Brand<T, B>`.
120
202
  */
121
203
  withBrand<B extends string>(brand: B): Converter<Brand<T, B>, TC>;
122
204
  /**
123
- * {@inheritDoc Converter.withDefault}
205
+ * Returns a Converter which always succeeds with a default value rather than failing.
206
+ * @param defaultValue - The default value to use if conversion fails.
124
207
  */
125
208
  withDefault<TD = T>(defaultValue: TD): DefaultingConverter<T, TD, TC>;
126
209
  or(other: Converter<T, TC>): Converter<T, TC>;
@@ -129,7 +212,10 @@ export declare class BaseConverter<T, TC = unknown> implements Converter<T, TC>
129
212
  */
130
213
  protected _context(supplied?: TC): TC | undefined;
131
214
  /**
132
- * {@inheritDoc Converter.withFormattedError}
215
+ * Creates a new {@link Converter} which is derived from this one but which returns an
216
+ * error message formatted by the supplied formatter if the conversion fails.
217
+ * @param formatter - The formatter to be applied.
218
+ * @returns A new {@link Converter} returning `<T>`.
133
219
  */
134
220
  withFormattedError(formatter: ConversionErrorFormatter<TC>): Converter<T, TC>;
135
221
  /**