@fgv/ts-utils 5.0.2 → 5.1.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +152 -84
  2. package/dist/index.js +2 -2
  3. package/dist/packlets/base/messageAggregator.js +6 -6
  4. package/dist/packlets/base/result.js +39 -39
  5. package/dist/packlets/base/utils.js +47 -0
  6. package/dist/packlets/collections/aggregatedResultMap.js +722 -0
  7. package/dist/packlets/collections/collector.js +9 -9
  8. package/dist/packlets/collections/collectorValidator.js +4 -4
  9. package/dist/packlets/collections/converters.js +39 -0
  10. package/dist/packlets/collections/convertingCollectorValidator.js +3 -3
  11. package/dist/packlets/collections/convertingResultMap.js +208 -0
  12. package/dist/packlets/collections/index.js +4 -0
  13. package/dist/packlets/collections/keyValueConverters.js +1 -4
  14. package/dist/packlets/collections/readOnlyConvertingResultMap.js +193 -0
  15. package/dist/packlets/collections/resultMapValidator.js +50 -6
  16. package/dist/packlets/collections/validatingConvertingResultMap.js +78 -0
  17. package/dist/packlets/conversion/advancedConverters.js +249 -0
  18. package/dist/packlets/conversion/baseConverter.js +23 -16
  19. package/dist/packlets/conversion/basicConverters.js +571 -0
  20. package/dist/packlets/conversion/converters.js +3 -617
  21. package/dist/packlets/conversion/defaultingConverter.js +21 -15
  22. package/dist/packlets/logging/bootLogger.js +122 -0
  23. package/dist/packlets/logging/index.js +1 -0
  24. package/dist/packlets/logging/logReporter.js +32 -1
  25. package/dist/packlets/logging/logger.js +25 -5
  26. package/dist/packlets/validation/classes.js +1 -0
  27. package/dist/packlets/validation/compositeId.js +60 -0
  28. package/dist/packlets/validation/field.js +1 -1
  29. package/dist/packlets/validation/genericValidator.js +24 -10
  30. package/dist/packlets/validation/object.js +3 -6
  31. package/dist/packlets/validation/validators.js +12 -0
  32. package/dist/ts-utils.d.ts +1633 -200
  33. package/dist/tsdoc-metadata.json +1 -1
  34. package/lib/index.d.ts +2 -2
  35. package/lib/index.js +2 -1
  36. package/lib/packlets/base/mapResults.d.ts +3 -3
  37. package/lib/packlets/base/messageAggregator.d.ts +6 -6
  38. package/lib/packlets/base/messageAggregator.js +6 -6
  39. package/lib/packlets/base/result.d.ts +74 -51
  40. package/lib/packlets/base/result.js +39 -39
  41. package/lib/packlets/base/utils.d.ts +42 -0
  42. package/lib/packlets/base/utils.js +52 -0
  43. package/lib/packlets/collections/aggregatedResultMap.d.ts +433 -0
  44. package/lib/packlets/collections/aggregatedResultMap.js +728 -0
  45. package/lib/packlets/collections/collector.d.ts +11 -10
  46. package/lib/packlets/collections/collector.js +9 -9
  47. package/lib/packlets/collections/collectorValidator.d.ts +12 -10
  48. package/lib/packlets/collections/collectorValidator.js +4 -4
  49. package/lib/packlets/collections/converters.d.ts +18 -0
  50. package/lib/packlets/collections/converters.js +42 -0
  51. package/lib/packlets/collections/convertingCollector.d.ts +4 -4
  52. package/lib/packlets/collections/convertingCollectorValidator.d.ts +10 -7
  53. package/lib/packlets/collections/convertingCollectorValidator.js +3 -3
  54. package/lib/packlets/collections/convertingResultMap.d.ts +176 -0
  55. package/lib/packlets/collections/convertingResultMap.js +213 -0
  56. package/lib/packlets/collections/index.d.ts +4 -0
  57. package/lib/packlets/collections/index.js +4 -0
  58. package/lib/packlets/collections/keyValueConverters.d.ts +1 -4
  59. package/lib/packlets/collections/keyValueConverters.js +1 -4
  60. package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts +153 -0
  61. package/lib/packlets/collections/readOnlyConvertingResultMap.js +197 -0
  62. package/lib/packlets/collections/readonlyResultMap.d.ts +7 -7
  63. package/lib/packlets/collections/resultMap.d.ts +108 -2
  64. package/lib/packlets/collections/resultMapValidator.d.ts +45 -11
  65. package/lib/packlets/collections/resultMapValidator.js +52 -7
  66. package/lib/packlets/collections/validatingCollector.d.ts +5 -5
  67. package/lib/packlets/collections/validatingConvertingCollector.d.ts +3 -3
  68. package/lib/packlets/collections/validatingConvertingResultMap.d.ts +102 -0
  69. package/lib/packlets/collections/validatingConvertingResultMap.js +83 -0
  70. package/lib/packlets/collections/validatingResultMap.d.ts +1 -1
  71. package/lib/packlets/conversion/advancedConverters.d.ts +170 -0
  72. package/lib/packlets/conversion/advancedConverters.js +258 -0
  73. package/lib/packlets/conversion/baseConverter.d.ts +39 -23
  74. package/lib/packlets/conversion/baseConverter.js +23 -16
  75. package/lib/packlets/conversion/basicConverters.d.ts +470 -0
  76. package/lib/packlets/conversion/basicConverters.js +595 -0
  77. package/lib/packlets/conversion/converter.d.ts +7 -0
  78. package/lib/packlets/conversion/converters.d.ts +2 -535
  79. package/lib/packlets/conversion/converters.js +17 -639
  80. package/lib/packlets/conversion/defaultingConverter.d.ts +20 -16
  81. package/lib/packlets/conversion/defaultingConverter.js +21 -15
  82. package/lib/packlets/logging/bootLogger.d.ts +84 -0
  83. package/lib/packlets/logging/bootLogger.js +126 -0
  84. package/lib/packlets/logging/index.d.ts +1 -0
  85. package/lib/packlets/logging/index.js +1 -0
  86. package/lib/packlets/logging/logReporter.d.ts +18 -3
  87. package/lib/packlets/logging/logReporter.js +31 -0
  88. package/lib/packlets/logging/logger.d.ts +39 -6
  89. package/lib/packlets/logging/logger.js +26 -5
  90. package/lib/packlets/validation/classes.d.ts +1 -0
  91. package/lib/packlets/validation/classes.js +3 -1
  92. package/lib/packlets/validation/compositeId.d.ts +29 -0
  93. package/lib/packlets/validation/compositeId.js +64 -0
  94. package/lib/packlets/validation/field.d.ts +1 -1
  95. package/lib/packlets/validation/field.js +1 -1
  96. package/lib/packlets/validation/genericValidator.d.ts +15 -11
  97. package/lib/packlets/validation/genericValidator.js +24 -10
  98. package/lib/packlets/validation/object.d.ts +3 -6
  99. package/lib/packlets/validation/object.js +3 -6
  100. package/lib/packlets/validation/traits.d.ts +3 -3
  101. package/lib/packlets/validation/validator.d.ts +7 -0
  102. package/lib/packlets/validation/validators.d.ts +10 -0
  103. package/lib/packlets/validation/validators.js +13 -0
  104. package/package.json +14 -14
package/README.md CHANGED
@@ -1,132 +1,200 @@
1
- <div align="center">
2
- <h1>ts-utils</h1>
3
- Assorted Typescript Utilities
4
- </div>
1
+ # @fgv/ts-utils
5
2
 
6
- <hr/>
7
-
8
- ## Summary
9
-
10
- Assorted typescript utilities that I'm tired of copying from project to project. Most notable and closest to production-ready are:
11
- * Result\<T\> - Easily combine inline and exception-based error handling
12
- * Converter\<T\> - Conversion framework especially useful for type-safe processing of JSON
13
-
14
- ---
15
-
16
- - [Summary](#summary)
17
- - [Installation](#installation)
18
- - [API Documentation](#api-documentation)
19
- - [Overview](#overview)
20
- - [The Result Pattern](#the-result-pattern)
21
- - [Converters](#converters)
22
- - [API](#api)
23
- - [Result\<T\>](#resultt)
24
- - [Converter\<T\>](#convertert)
3
+ Type-safe utilities for TypeScript — Result pattern, composable converters and validators, and Result-aware collections.
25
4
 
26
5
  ## Installation
27
6
 
28
- With npm:
29
7
  ```sh
30
8
  npm install @fgv/ts-utils
31
9
  ```
32
10
 
33
- ## API Documentation
34
- Extracted API documentation is [here](./docs/ts-utils.md).
35
-
36
11
  ## Overview
37
- ### The Result Pattern
38
12
 
39
- A Result\<T\> represents the success or failure of executing some operation. A successful result contains a return *value* of type *T*, while a failure result contains an error message of type *string*. Taken by itself, the use of Result\<T\> allows for simple inline error handling.
13
+ `@fgv/ts-utils` provides a cohesive set of utilities built around the Result pattern. Instead of throwing exceptions for expected error conditions, all fallible operations return `Result<T>` making errors explicit in the type system and enabling safe, composable error handling.
14
+
15
+ The library is organized into six packlets, each with its own detailed documentation.
16
+
17
+ ## The Result Pattern
18
+
19
+ A `Result<T>` is either a `Success<T>` containing a value, or a `Failure<T>` containing an error message. This replaces exception-based error handling with explicit, chainable results.
20
+
21
+ ### Creating Results
40
22
 
41
- ```ts
42
- const result = functionReturningResult();
43
- if (result.isSuccess()) {
44
- functionAcceptingT(result.value);
23
+ ```typescript
24
+ import { Result, succeed, fail, captureResult } from '@fgv/ts-utils';
25
+
26
+ function divide(a: number, b: number): Result<number> {
27
+ if (b === 0) {
28
+ return fail('Division by zero');
29
+ }
30
+ return succeed(a / b);
45
31
  }
46
- else {
47
- console.log(result.error);
32
+
33
+ // Wrap throwing code
34
+ function parseJson(text: string): Result<unknown> {
35
+ return captureResult(() => JSON.parse(text));
48
36
  }
49
37
  ```
50
38
 
51
- Use *succeed\<T>()* and *fail\<T\>()* to return success or failure:
39
+ ### Extracting Values
52
40
 
53
- ```ts
54
- function thisFunctionSucceeds(): string {
55
- return succeed('I succeeded!');
56
- }
41
+ ```typescript
42
+ // In setup/initialization — converts failure to exception
43
+ const config = loadConfig().orThrow();
44
+
45
+ // Safe fallback
46
+ const port = getPort().orDefault(3000);
47
+ ```
48
+
49
+ ### Chaining Operations
57
50
 
58
- function thisFunctionFails(): number {
59
- return fail('Oops! I failed');
51
+ ```typescript
52
+ function processData(input: string): Result<ProcessedData> {
53
+ return parseInput(input)
54
+ .onSuccess((parsed) => validate(parsed))
55
+ .onSuccess((valid) => transform(valid));
60
56
  }
61
57
  ```
62
58
 
63
- Use *orDefault* when a failure can be safely ignored:
64
- ```ts
65
- // returns undefined on failure
66
- const value1: string|undefined = functionReturningResult('whatever').orDefault();
59
+ ### Error Context
67
60
 
68
- // returns 'oops' on failure
69
- const value2: string = functionReturningResult('whatever').orDefault('oops');
61
+ ```typescript
62
+ function loadUser(id: string): Result<User> {
63
+ return fetchUser(id)
64
+ .withErrorFormat((msg) => `Failed to load user ${id}: ${msg}`);
65
+ }
70
66
  ```
71
67
 
72
- The *orThrow* method converts a failure result to an exception, for use in contexts (such as constructors) in which an exception is the most appropriate way to handle errors.
68
+ ### Error Aggregation
69
+
70
+ ```typescript
71
+ import { mapResults, MessageAggregator } from '@fgv/ts-utils';
72
+
73
+ // Aggregate array of results
74
+ const results = items.map((item) => processItem(item));
75
+ return mapResults(results); // All must succeed, or errors are aggregated
73
76
 
74
- ```ts
75
- constructor(param: string) {
76
- this._param = validateReturnsResult(param).orThrow();
77
+ // Collect errors manually
78
+ const aggregator = new MessageAggregator();
79
+ validateA(data).aggregateError(aggregator);
80
+ validateB(data).aggregateError(aggregator);
81
+ if (aggregator.hasMessages) {
82
+ return fail(aggregator.toString('; '));
77
83
  }
78
84
  ```
79
85
 
80
- The *captureResult* function converts an exception to a failure for simplified inline processing.
86
+ ### Factory Pattern
81
87
 
82
- ```ts
83
- class Thing {
84
- static create(param: string): Result<Thing> {
85
- return captureResult(new Thing(param));
86
- }
88
+ ```typescript
89
+ class ResourceManager {
90
+ private constructor(private config: Config) { /* may throw */ }
91
+
92
+ public static create(params: Params): Result<ResourceManager> {
93
+ return validateParams(params)
94
+ .onSuccess((valid) => loadConfig(valid))
95
+ .onSuccess((config) => captureResult(() => new ResourceManager(config)));
96
+ }
87
97
  }
88
98
  ```
89
99
 
90
- Other methods and helpers allow for chaining and conversion of results, working with mulitple results and more. See the [API documentation](#resultt) for details.
100
+ ### Best Practices
101
+
102
+ - Return `Result<T>` from fallible operations — never throw in business logic
103
+ - Use `orThrow()` only in setup/initialization
104
+ - Prefer chaining over intermediate variables
105
+ - Add context with `withErrorFormat()` as errors propagate
106
+ - Use `MessageAggregator` for collecting multiple errors
91
107
 
92
- ### Converters
108
+ [Full Result pattern documentation &rarr;](./src/packlets/base/README.md)
93
109
 
94
- The basic *Converter\<T\>* implements a *convert* method which converts *unknown* to *T*, using the result pattern to report success or failure.
110
+ ## Type-Safe Conversion
95
111
 
96
- ```ts
97
- class Converter<T> {
98
- public convert(from: unknown): Result<T>;
112
+ `Converter<T>` converts `unknown` to `T`, returning `Result<T>`. Converters compose to build type-safe pipelines for JSON parsing and data transformation.
113
+
114
+ ```typescript
115
+ import { Converters } from '@fgv/ts-utils';
116
+
117
+ interface IConfig {
118
+ host: string;
119
+ port: number;
120
+ debug: boolean;
121
+ tags: string[];
99
122
  }
123
+
124
+ const configConverter = Converters.object<IConfig>({
125
+ host: Converters.string,
126
+ port: Converters.number,
127
+ debug: Converters.boolean,
128
+ tags: Converters.arrayOf(Converters.string),
129
+ });
130
+
131
+ const config = configConverter.convert(json).orThrow();
100
132
  ```
101
133
 
102
- But built-in converters, including converters which can extract a field for an object or which apply converters according to the shape of some object can be composed to provide compact and legible type-safe conversion from anything to a strongly typed Typescript object:
134
+ Converters support a fluent modifier API:
103
135
 
104
- ```ts
105
- interface Thing {
106
- title: string;
107
- count: number;
108
- isGood: boolean;
109
- hints: string[];
110
- }
136
+ ```typescript
137
+ Converters.number
138
+ .withConstraint((n) => n > 0 && n < 65536, { description: 'valid port' })
139
+ .withBrand<'Port'>('Port');
140
+ ```
141
+
142
+ [Full conversion documentation &rarr;](./src/packlets/conversion/README.md)
143
+
144
+ ## In-Place Validation
145
+
146
+ `Validator<T>` verifies a value is of type `T` without creating a new object — preserving object identity and prototype chains.
147
+
148
+ ```typescript
149
+ import { Validators } from '@fgv/ts-utils';
111
150
 
112
- const thingConverter = Converters.object<Thing>({
113
- title: Converters.string,
114
- count: Converters.number,
115
- isGood: Converters.boolean,
116
- hints: Converters.array(Converters.string),
151
+ const userValidator = Validators.object<IUser>({
152
+ name: Validators.string,
153
+ age: Validators.number,
154
+ active: Validators.boolean,
117
155
  });
118
156
 
119
- // gets a Thing or throws an error
120
- const thing: Things = thingConverter.convert(json).orThrow();
157
+ const result = userValidator.validate(input); // Result<IUser>
121
158
  ```
122
159
 
123
- Everything is strongly-typed, so Intellisense will autocomplete properties and highlight errors in the object supplied to *Converters.object*.
160
+ Converters and Validators interoperate use either as field definitions in object converters.
124
161
 
125
- Other helpers and methods enable optional values or fields, chaining of results and a variety of other conversions and transformations.
162
+ [Full validation documentation &rarr;](./src/packlets/validation/README.md)
126
163
 
127
- ## API
164
+ ## Type-Safe Collections
128
165
 
129
- ### Result\<T\>
166
+ `ResultMap` provides a `Map`-like API where all operations return `DetailedResult` with discriminated details (`'added'`, `'exists'`, `'not-found'`, etc.):
130
167
 
131
- ### Converter\<T\>
168
+ ```typescript
169
+ import { ResultMap } from '@fgv/ts-utils';
132
170
 
171
+ const map = new ResultMap<string, number>();
172
+ map.add('key', 42); // detail: 'added'
173
+ map.add('key', 99); // detail: 'exists' (failure)
174
+ map.get('key'); // detail: 'exists', value: 42
175
+ map.get('missing'); // detail: 'not-found' (failure)
176
+ ```
177
+
178
+ The collections packlet also provides `Collector` (append-only with write-once indexing), `ValidatingResultMap` (weakly-typed access with validation), `ConvertingResultMap` (lazy conversion with caching), and `AggregatedResultMap` (multi-collection composite IDs).
179
+
180
+ [Full collections documentation &rarr;](./src/packlets/collections/README.md)
181
+
182
+ ## Additional Utilities
183
+
184
+ - **[Logging](./src/packlets/logging/README.md)** — Level-based logging with `ConsoleLogger`, `InMemoryLogger` (for testing), and `LogReporter` for Result-aware reporting.
185
+ - **[Hashing](./src/packlets/hash/README.md)** — Deterministic hashing of nested objects with `Crc32Normalizer`, producing consistent hashes regardless of property order.
186
+
187
+ ## Packlet Reference
188
+
189
+ | Packlet | Description | Documentation |
190
+ |---------|-------------|---------------|
191
+ | `base` | Result pattern, error aggregation, branded types | [README](./src/packlets/base/README.md) |
192
+ | `conversion` | Type-safe converters (`unknown` &rarr; `T`) | [README](./src/packlets/conversion/README.md) |
193
+ | `validation` | In-place validators (verify without transforming) | [README](./src/packlets/validation/README.md) |
194
+ | `collections` | Result-aware Map/Collection with validation layers | [README](./src/packlets/collections/README.md) |
195
+ | `logging` | Level-based logging with Result integration | [README](./src/packlets/logging/README.md) |
196
+ | `hash` | Deterministic object hashing | [README](./src/packlets/hash/README.md) |
197
+
198
+ ## API Documentation
199
+
200
+ Extracted API documentation is [here](./docs/ts-utils.md).
package/dist/index.js CHANGED
@@ -24,9 +24,9 @@ import * as Conversion from './packlets/conversion';
24
24
  import * as Hash from './packlets/hash';
25
25
  import * as Logging from './packlets/logging';
26
26
  import * as Validation from './packlets/validation';
27
- import { Collector, ConvertingCollector, ResultMap, ValidatingCollector, ValidatingConvertingCollector, ValidatingResultMap } from './packlets/collections';
27
+ import { AggregatedResultMap, Collector, ConvertingCollector, ResultMap, ValidatingCollector, ValidatingConvertingCollector, ValidatingResultMap } from './packlets/collections';
28
28
  import { Converters, ObjectConverter, StringConverter } from './packlets/conversion';
29
29
  import { Validators } from './packlets/validation';
30
30
  export * from './packlets/base';
31
- export { Collections, Collector, ConvertingCollector, Conversion, Converters, Hash, Logging, ObjectConverter, ResultMap, StringConverter, ValidatingCollector, ValidatingConvertingCollector, ValidatingResultMap, Validation, Validators };
31
+ export { AggregatedResultMap, Collections, Collector, ConvertingCollector, Conversion, Converters, Hash, Logging, ObjectConverter, ResultMap, StringConverter, ValidatingCollector, ValidatingConvertingCollector, ValidatingResultMap, Validation, Validators };
32
32
  //# sourceMappingURL=index.js.map
@@ -36,25 +36,25 @@ export class MessageAggregator {
36
36
  this._messages = errors ? Array.from(errors) : [];
37
37
  }
38
38
  /**
39
- * {@inheritdoc IMessageAggregator.hasMessages}
39
+ * {@inheritDoc IMessageAggregator.hasMessages}
40
40
  */
41
41
  get hasMessages() {
42
42
  return this._messages.length > 0;
43
43
  }
44
44
  /**
45
- * {@inheritdoc IMessageAggregator.numMessages}
45
+ * {@inheritDoc IMessageAggregator.numMessages}
46
46
  */
47
47
  get numMessages() {
48
48
  return this._messages.length;
49
49
  }
50
50
  /**
51
- * {@inheritdoc IMessageAggregator.messages}
51
+ * {@inheritDoc IMessageAggregator.messages}
52
52
  */
53
53
  get messages() {
54
54
  return this._messages;
55
55
  }
56
56
  /**
57
- * {@inheritdoc IMessageAggregator.addMessage}
57
+ * {@inheritDoc IMessageAggregator.addMessage}
58
58
  */
59
59
  addMessage(message) {
60
60
  if (message) {
@@ -63,7 +63,7 @@ export class MessageAggregator {
63
63
  return this;
64
64
  }
65
65
  /**
66
- * {@inheritdoc IMessageAggregator.addMessages}
66
+ * {@inheritDoc IMessageAggregator.addMessages}
67
67
  */
68
68
  addMessages(messages) {
69
69
  if (messages && messages.length > 0) {
@@ -72,7 +72,7 @@ export class MessageAggregator {
72
72
  return this;
73
73
  }
74
74
  /**
75
- * {@inheritdoc IMessageAggregator.toString}
75
+ * {@inheritDoc IMessageAggregator.toString}
76
76
  */
77
77
  toString(separator) {
78
78
  return this._messages.join(separator !== null && separator !== void 0 ? separator : '\n');
@@ -40,7 +40,7 @@ export class Success {
40
40
  */
41
41
  constructor(value) {
42
42
  /**
43
- * {@inheritdoc IResult.success}
43
+ * {@inheritDoc IResult.success}
44
44
  */
45
45
  this.success = true;
46
46
  /**
@@ -56,13 +56,13 @@ export class Success {
56
56
  return this._value;
57
57
  }
58
58
  /**
59
- * {@inheritdoc IResult.isSuccess}
59
+ * {@inheritDoc IResult.isSuccess}
60
60
  */
61
61
  isSuccess() {
62
62
  return true;
63
63
  }
64
64
  /**
65
- * {@inheritdoc IResult.isFailure}
65
+ * {@inheritDoc IResult.isFailure}
66
66
  */
67
67
  isFailure() {
68
68
  return false;
@@ -75,58 +75,58 @@ export class Success {
75
75
  return (_a = this._value) !== null && _a !== void 0 ? _a : dflt;
76
76
  }
77
77
  /**
78
- * {@inheritdoc IResult.getValueOrThrow}
79
- * @deprecated Use {@link Success.(orThrow:1) | orThrow(logger)} or {@link Success.(orThrow:2) | orThrow(formatter)} instead.
78
+ * {@inheritDoc IResult.getValueOrThrow}
79
+ * @deprecated Use {@link Success.orThrow | orThrow(logger)} or {@link Success.orThrow | orThrow(formatter)} instead.
80
80
  */
81
81
  getValueOrThrow(__logger) {
82
82
  return this._value;
83
83
  }
84
84
  /**
85
- * {@inheritdoc IResult.getValueOrDefault}
86
- * @deprecated Use {@link Success.(orDefault:1) | orDefault(T)} or {@link Success.(orDefault:2) | orDefault()} instead.
85
+ * {@inheritDoc IResult.getValueOrDefault}
86
+ * @deprecated Use {@link Success.orDefault | orDefault(T)} or {@link Success.orDefault | orDefault()} instead.
87
87
  */
88
88
  getValueOrDefault(dflt) {
89
89
  var _a;
90
90
  return (_a = this._value) !== null && _a !== void 0 ? _a : dflt;
91
91
  }
92
92
  /**
93
- * {@inheritdoc IResult.onSuccess}
93
+ * {@inheritDoc IResult.onSuccess}
94
94
  */
95
95
  onSuccess(cb) {
96
96
  return cb(this._value);
97
97
  }
98
98
  /**
99
- * {@inheritdoc IResult.onFailure}
99
+ * {@inheritDoc IResult.onFailure}
100
100
  */
101
101
  onFailure(__) {
102
102
  return this;
103
103
  }
104
104
  /**
105
- * {@inheritdoc IResult.withErrorFormat}
105
+ * {@inheritDoc IResult.withErrorFormat}
106
106
  */
107
107
  withErrorFormat(__cb) {
108
108
  return this;
109
109
  }
110
110
  /**
111
- * {@inheritdoc IResult.withFailureDetail}
111
+ * {@inheritDoc IResult.withFailureDetail}
112
112
  */
113
113
  withFailureDetail(__detail) {
114
114
  return succeedWithDetail(this._value);
115
115
  }
116
116
  /**
117
- * {@inheritdoc IResult.withDetail}
117
+ * {@inheritDoc IResult.withDetail}
118
118
  */
119
119
  withDetail(detail, successDetail) {
120
120
  return succeedWithDetail(this._value, successDetail !== null && successDetail !== void 0 ? successDetail : detail);
121
121
  }
122
122
  /**
123
- * {@inheritdoc IResult.aggregateError}
123
+ * {@inheritDoc IResult.aggregateError}
124
124
  */
125
125
  aggregateError(__errors, __formatter) {
126
126
  return this;
127
127
  }
128
128
  /**
129
- * {@inheritdoc IResult.report}
129
+ * {@inheritDoc IResult.report}
130
130
  */
131
131
  report(reporter, options) {
132
132
  var _a;
@@ -156,7 +156,7 @@ export class Failure {
156
156
  */
157
157
  constructor(message) {
158
158
  /**
159
- * {@inheritdoc IResult.success}
159
+ * {@inheritDoc IResult.success}
160
160
  */
161
161
  this.success = false;
162
162
  /**
@@ -172,13 +172,13 @@ export class Failure {
172
172
  return this._message;
173
173
  }
174
174
  /**
175
- * {@inheritdoc IResult.isSuccess}
175
+ * {@inheritDoc IResult.isSuccess}
176
176
  */
177
177
  isSuccess() {
178
178
  return false;
179
179
  }
180
180
  /**
181
- * {@inheritdoc IResult.isFailure}
181
+ * {@inheritDoc IResult.isFailure}
182
182
  */
183
183
  isFailure() {
184
184
  return true;
@@ -198,8 +198,8 @@ export class Failure {
198
198
  return dflt;
199
199
  }
200
200
  /**
201
- * {@inheritdoc IResult.getValueOrThrow}
202
- * @deprecated Use {@link Failure.(orThrow:1) | orThrow(logger)} or {@link Failure.(orThrow:2) | orThrow(formatter)} instead.
201
+ * {@inheritDoc IResult.getValueOrThrow}
202
+ * @deprecated Use {@link Failure.orThrow | orThrow(logger)} or {@link Failure.orThrow | orThrow(formatter)} instead.
203
203
  */
204
204
  getValueOrThrow(logger) {
205
205
  if (logger !== undefined) {
@@ -208,44 +208,44 @@ export class Failure {
208
208
  throw new Error(this._message);
209
209
  }
210
210
  /**
211
- * {@inheritdoc IResult.getValueOrDefault}
212
- * @deprecated Use {@link Failure.(orDefault:1) | orDefault(T)} or {@link Failure.(orDefault:2) | orDefault()} instead.
211
+ * {@inheritDoc IResult.getValueOrDefault}
212
+ * @deprecated Use {@link Failure.orDefault | orDefault(T)} or {@link Failure.orDefault | orDefault()} instead.
213
213
  */
214
214
  getValueOrDefault(dflt) {
215
215
  return dflt;
216
216
  }
217
217
  /**
218
- * {@inheritdoc IResult.onSuccess}
218
+ * {@inheritDoc IResult.onSuccess}
219
219
  */
220
220
  onSuccess(__) {
221
221
  return new Failure(this._message);
222
222
  }
223
223
  /**
224
- * {@inheritdoc IResult.onFailure}
224
+ * {@inheritDoc IResult.onFailure}
225
225
  */
226
226
  onFailure(cb) {
227
227
  return cb(this._message);
228
228
  }
229
229
  /**
230
- * {@inheritdoc IResult.withErrorFormat}
230
+ * {@inheritDoc IResult.withErrorFormat}
231
231
  */
232
232
  withErrorFormat(cb) {
233
233
  return fail(cb(this._message));
234
234
  }
235
235
  /**
236
- * {@inheritdoc IResult.withFailureDetail}
236
+ * {@inheritDoc IResult.withFailureDetail}
237
237
  */
238
238
  withFailureDetail(detail) {
239
239
  return failWithDetail(this._message, detail);
240
240
  }
241
241
  /**
242
- * {@inheritdoc IResult.withDetail}
242
+ * {@inheritDoc IResult.withDetail}
243
243
  */
244
244
  withDetail(detail, __successDetail) {
245
245
  return failWithDetail(this._message, detail);
246
246
  }
247
247
  /**
248
- * {@inheritdoc IResult.aggregateError}
248
+ * {@inheritDoc IResult.aggregateError}
249
249
  */
250
250
  aggregateError(errors, formatter) {
251
251
  const message = formatter ? formatter(this._message) : this._message;
@@ -253,7 +253,7 @@ export class Failure {
253
253
  return this;
254
254
  }
255
255
  /**
256
- * {@inheritdoc IResult.report}
256
+ * {@inheritDoc IResult.report}
257
257
  */
258
258
  report(reporter, options) {
259
259
  var _a, _b, _c;
@@ -294,7 +294,7 @@ export function succeed(value) {
294
294
  return new Success(value);
295
295
  }
296
296
  /**
297
- * {@inheritdoc succeed}
297
+ * {@inheritDoc succeed}
298
298
  * @public
299
299
  */
300
300
  export function succeeds(value) {
@@ -312,7 +312,7 @@ export function fail(message) {
312
312
  return new Failure(message);
313
313
  }
314
314
  /**
315
- * {@inheritdoc fail}
315
+ * {@inheritDoc fail}
316
316
  * @public
317
317
  */
318
318
  export function fails(message) {
@@ -378,7 +378,7 @@ export class DetailedSuccess extends Success {
378
378
  * Propagates this {@link DetailedSuccess}.
379
379
  * @remarks
380
380
  * Failure does not mutate return type so we can return this event directly.
381
- * @param _cb - {@link DetailedFailureContinuation | Failure callback} to be called
381
+ * @param __cb - {@link DetailedFailureContinuation | Failure callback} to be called
382
382
  * on a {@link DetailedResult} in case of failure (ignored).
383
383
  * @returns `this`
384
384
  */
@@ -386,13 +386,13 @@ export class DetailedSuccess extends Success {
386
386
  return this;
387
387
  }
388
388
  /**
389
- * {@inheritdoc Success.withErrorFormat}
389
+ * {@inheritDoc Success.withErrorFormat}
390
390
  */
391
391
  withErrorFormat(cb) {
392
392
  return this;
393
393
  }
394
394
  /**
395
- * {@inheritdoc IResult.report}
395
+ * {@inheritDoc IResult.report}
396
396
  */
397
397
  report(reporter, options) {
398
398
  var _a;
@@ -455,7 +455,7 @@ export class DetailedFailure extends Failure {
455
455
  * @remarks
456
456
  * Mutates the success type as the success callback would have, but does not
457
457
  * call the success callback.
458
- * @param _cb - {@link DetailedSuccessContinuation | Success callback} to be called
458
+ * @param __cb - {@link DetailedSuccessContinuation | Success callback} to be called
459
459
  * on a {@link DetailedResult} in case of success (ignored).
460
460
  * @returns A new {@link DetailedFailure | DetailedFailure<TN, TD>} which contains
461
461
  * the error message and detail from this one.
@@ -473,13 +473,13 @@ export class DetailedFailure extends Failure {
473
473
  return cb(this._message, this._detail);
474
474
  }
475
475
  /**
476
- * {@inheritdoc IResult.withErrorFormat}
476
+ * {@inheritDoc IResult.withErrorFormat}
477
477
  */
478
478
  withErrorFormat(cb) {
479
479
  return failWithDetail(cb(this._message, this._detail), this._detail);
480
480
  }
481
481
  /**
482
- * {@inheritdoc IResult.aggregateError}
482
+ * {@inheritDoc IResult.aggregateError}
483
483
  */
484
484
  aggregateError(errors, formatter) {
485
485
  const message = formatter ? formatter(this._message, this._detail) : this._message;
@@ -487,7 +487,7 @@ export class DetailedFailure extends Failure {
487
487
  return this;
488
488
  }
489
489
  /**
490
- * {@inheritdoc IResult.report}
490
+ * {@inheritDoc IResult.report}
491
491
  */
492
492
  report(reporter, options) {
493
493
  var _a, _b;
@@ -548,7 +548,7 @@ export function succeedWithDetail(value, detail) {
548
548
  return new DetailedSuccess(value, detail);
549
549
  }
550
550
  /**
551
- * {@inheritdoc succeedWithDetail}
551
+ * {@inheritDoc succeedWithDetail}
552
552
  * @public
553
553
  */
554
554
  export function succeedsWithDetail(value, detail) {
@@ -569,7 +569,7 @@ export function failWithDetail(message, detail) {
569
569
  return new DetailedFailure(message, detail);
570
570
  }
571
571
  /**
572
- * {@inheritdoc failWithDetail}
572
+ * {@inheritDoc failWithDetail}
573
573
  * @public
574
574
  */
575
575
  export function failsWithDetail(message, detail) {