@fgv/ts-extras 2.1.1-alpha.3 → 3.0.0-alpha.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 CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@fgv/ts-extras",
3
3
  "entries": [
4
+ {
5
+ "version": "3.0.0",
6
+ "tag": "@fgv/ts-extras_v3.0.0",
7
+ "date": "Mon, 22 Jan 2024 07:00:18 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "refactor hash implementation"
12
+ },
13
+ {
14
+ "comment": "refactor and cleanup"
15
+ },
16
+ {
17
+ "comment": "Factor extras into their own package"
18
+ }
19
+ ]
20
+ }
21
+ },
4
22
  {
5
23
  "version": "2.2.0",
6
24
  "tag": "@fgv/ts-extras_v2.2.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Change Log - @fgv/ts-extras
2
2
 
3
- This log was last generated on Thu, 18 Jan 2024 05:45:04 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 22 Jan 2024 07:00:18 GMT and should not be manually modified.
4
+
5
+ ## 3.0.0
6
+ Mon, 22 Jan 2024 07:00:18 GMT
7
+
8
+ ### Updates
9
+
10
+ - refactor hash implementation
11
+ - refactor and cleanup
12
+ - Factor extras into their own package
4
13
 
5
14
  ## 2.2.0
6
15
  Thu, 18 Jan 2024 05:45:04 GMT
@@ -21,7 +21,7 @@ declare namespace Csv {
21
21
  export { Csv }
22
22
 
23
23
  /**
24
- * Options for {@link Csv.readCsvFileSync}
24
+ * Options for {@link Csv.readCsvFileSync | readCsvFileSync}
25
25
  * @beta
26
26
  */
27
27
  declare interface CsvOptions {
@@ -55,13 +55,13 @@ export { Experimental }
55
55
 
56
56
  /**
57
57
  * An experimental array template which extend built-in `Array` to include a handful
58
- * of predicates which return {@link Result | Result<T>}.
58
+ * of predicates which return `Result<T>`.
59
59
  * @beta
60
60
  */
61
61
  declare class ExtendedArray<T> extends Array<T> {
62
62
  readonly itemDescription: string;
63
63
  /**
64
- * Constructs an {@link Experimental.ExtendedArray}.
64
+ * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.
65
65
  * @param itemDescription - Brief description of the type of each item in this array.
66
66
  * @param items - The initial contents of the array.
67
67
  */
@@ -70,7 +70,7 @@ declare class ExtendedArray<T> extends Array<T> {
70
70
  * Type guard to determine if some arbitrary array is an
71
71
  * {@link Experimental.ExtendedArray}
72
72
  * @param a - The `Array` to be tested.
73
- * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray},
73
+ * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},
74
74
  * `false` otherwise.
75
75
  */
76
76
  static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T>;
@@ -78,42 +78,42 @@ declare class ExtendedArray<T> extends Array<T> {
78
78
  * Determines if this array contains exactly one element which matches
79
79
  * a supplied predicate.
80
80
  * @param predicate - The predicate function to be applied.
81
- * @returns Returns {@link Success | Success<T>} with the single matching
82
- * result if exactly one item matches `predicate`. Returns {@link Failure}
81
+ * @returns Returns `Success<T>` with the single matching
82
+ * result if exactly one item matches `predicate`. Returns `Failure<T>`
83
83
  * with an error message if there are no matches or more than one match.
84
84
  */
85
85
  single(predicate?: (item: T) => boolean): Result<T>;
86
86
  /**
87
- * Returns the first element of an {@link Experimental.ExtendedArray}. Fails with an
87
+ * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an
88
88
  * error message if the array is empty.
89
89
  * @param failMessage - Optional message to be displayed in the event of failure.
90
- * @returns Returns {@link Success | Success<T>} with the value of the first element
91
- * in the array, or {@link Failure} with an error message if the array is empty.
90
+ * @returns Returns `Success<T>` with the value of the first element
91
+ * in the array, or `Failure<T>` with an error message if the array is empty.
92
92
  */
93
93
  first(failMessage?: string): Result<T>;
94
94
  /**
95
- * Returns an array containing all elements of an {@link Experimental.ExtendedArray}. Fails with
96
- * an error message if the array is empty.
95
+ * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.
96
+ * Fails with an error message if the array is empty.
97
97
  * @param failMessage - Optional message to be displayed in the event of failure.
98
- * @returns Returns {@link Success | Success<T[]>} with a new (non-extended) `Array`
99
- * containing the elements of this array, or {@link Failure} with an error message
98
+ * @returns Returns `Success<T>` with a new (non-extended) `Array`
99
+ * containing the elements of this array, or `Failure<T>` with an error message
100
100
  * if the array is empty.
101
101
  */
102
102
  atLeastOne(failMessage?: string): Result<T[]>;
103
103
  /**
104
104
  * Gets a new (non-extended) `Array` containing all of the elements from this
105
- * {@link Experimental.ExtendedArray}.
105
+ * {@link Experimental.ExtendedArray | ExtendedArray}.
106
106
  * @returns A new (non-extended) `Array<T>`.
107
107
  */
108
108
  all(): T[];
109
109
  }
110
110
 
111
111
  /**
112
- * A helper function to create a {@link Converter} which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
112
+ * A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
113
113
  * @remarks
114
114
  * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot
115
115
  * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.
116
- * @param converter - {@link Converter} used to convert each item in the array
116
+ * @param converter - `Converter` used to convert each item in the array
117
117
  * @param ignoreErrors - Specifies treatment of unconvertible elements
118
118
  * @beta
119
119
  */
@@ -138,267 +138,267 @@ declare interface Formattable {
138
138
  /**
139
139
  * Formats an object using the supplied mustache template.
140
140
  * @param format - A mustache template used to format the object.
141
- * @returns {@link Success} with the resulting string, or {@link Failure}
142
- * with an error message if an error occurs.
143
- */
144
- format(format: string): Result<string>;
145
- }
146
-
147
- /**
148
- * Base class which adds common formatting.
149
- * @beta
141
+ * @returns `Success<string>` with the resulting string, or `Failure<string>`
142
+ * with an error message if an error occurs.
150
143
  */
151
- declare class FormattableBase {
152
- /**
153
- * Helper enables derived classes to add named details to a formatted presentation.
154
- * @param details - An array of detail description strings.
155
- * @param label - Label to use for the new detail.
156
- * @param value - Value to use for the new detail.
157
- * @internal
158
- */
159
- protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void;
160
- /**
161
- * {@inheritdoc Experimental.Formattable.format}
162
- */
163
- format(template: string): Result<string>;
164
- }
144
+ format(format: string): Result<string>;
145
+ }
165
146
 
147
+ /**
148
+ * Base class which adds common formatting.
149
+ * @beta
150
+ */
151
+ declare class FormattableBase {
166
152
  /**
167
- * Destination format for some formatted string.
168
- * @beta
153
+ * Helper enables derived classes to add named details to a formatted presentation.
154
+ * @param details - An array of detail description strings.
155
+ * @param label - Label to use for the new detail.
156
+ * @param value - Value to use for the new detail.
157
+ * @internal
169
158
  */
170
- declare type FormatTargets = 'text' | 'markdown' | 'embed';
171
-
159
+ protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void;
172
160
  /**
173
- * Type definition for a formatting function, which takes a `string` and an
174
- * item and returns {@link Result | Result<string>}.
175
- * @beta
161
+ * {@inheritdoc Experimental.Formattable.format}
176
162
  */
177
- declare type Formatter<T> = (format: string, item: T) => Result<string>;
163
+ format(template: string): Result<string>;
164
+ }
178
165
 
179
- /**
180
- * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable
181
- * different format methods per output target.
182
- * @beta
183
- */
184
- declare type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;
166
+ /**
167
+ * Destination format for some formatted string.
168
+ * @beta
169
+ */
170
+ declare type FormatTargets = 'text' | 'markdown' | 'embed';
185
171
 
186
- /**
187
- * A collection of {@link Experimental.Formatter | formatters} indexed by the
188
- * {@link Experimental.FormatTargets | default supported target formats}.
189
- * @beta
190
- */
191
- declare type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;
172
+ /**
173
+ * Type definition for a formatting function, which takes a `string` and an
174
+ * item and returns `Result<string>`.
175
+ * @beta
176
+ */
177
+ declare type Formatter<T> = (format: string, item: T) => Result<string>;
178
+
179
+ /**
180
+ * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable
181
+ * different format methods per output target.
182
+ * @beta
183
+ */
184
+ declare type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;
185
+
186
+ /**
187
+ * A collection of {@link Experimental.Formatter | formatters} indexed by the
188
+ * {@link Experimental.FormatTargets | default supported target formats}.
189
+ * @beta
190
+ */
191
+ declare type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;
192
192
 
193
- declare namespace Hash {
194
- export {
195
- Md5Normalizer
196
- }
193
+ declare namespace Hash {
194
+ export {
195
+ Md5Normalizer
197
196
  }
198
- export { Hash }
197
+ }
198
+ export { Hash }
199
+
200
+ /**
201
+ * @public
202
+ */
203
+ declare type JarFieldPicker<T extends JarRecord = JarRecord> = (record: T) => (keyof T)[];
204
+
205
+ /**
206
+ * Represents a single record in a JAR file
207
+ * @public
208
+ */
209
+ declare type JarRecord = Record<string, string | string[]>;
210
+
211
+ /**
212
+ * Options for a JAR record parser.
213
+ * @public
214
+ */
215
+ declare interface JarRecordParserOptions {
216
+ readonly arrayFields?: string[] | JarFieldPicker;
217
+ readonly fixedContinuationSize?: number;
218
+ }
219
+
220
+ /**
221
+ * A hashing normalizer which computes object
222
+ * hash using the MD5 algorithm.
223
+ * @public
224
+ */
225
+ declare class Md5Normalizer extends Hash_2.HashingNormalizer {
226
+ constructor();
227
+ static md5Hash(parts: string[]): string;
228
+ }
229
+
230
+ /**
231
+ * Reads a record-jar from an array of strings, each of which represents one
232
+ * line in the source file.
233
+ * @param lines - the array of strings to be parsed
234
+ * @param options - Optional parser configuration
235
+ * @returns a corresponding array of `Record<string, string>`
236
+ * @public
237
+ */
238
+ declare function parseRecordJarLines(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]>;
199
239
 
240
+ /**
241
+ * Simple implementation of a possibly open-ended range of some comparable
242
+ * type `<T>` with test and formatting.
243
+ * @public
244
+ */
245
+ declare class RangeOf<T> implements RangeOfProperties<T> {
200
246
  /**
201
- * @public
247
+ * Minimum extent of the range.
202
248
  */
203
- declare type JarFieldPicker<T extends JarRecord = JarRecord> = (record: T) => (keyof T)[];
204
-
249
+ readonly min?: T;
205
250
  /**
206
- * Represents a single record in a JAR file
207
- * @public
251
+ * Maximum extent of the range.
208
252
  */
209
- declare type JarRecord = Record<string, string | string[]>;
210
-
253
+ readonly max?: T;
211
254
  /**
212
- * Options for a JAR record parser.
213
- * @public
255
+ * Creates a new {@link Experimental.RangeOf | RangeOf<T>}.
256
+ * @param min - Optional minimum extent of the range.
257
+ * @param max - Optional maximum extent of the range.
214
258
  */
215
- declare interface JarRecordParserOptions {
216
- readonly arrayFields?: string[] | JarFieldPicker;
217
- readonly fixedContinuationSize?: number;
218
- }
219
-
259
+ constructor(min?: T, max?: T);
220
260
  /**
221
- * A {@link Hash.HashingNormalizer | hashing normalizer} which computes object
222
- * hash using the MD5 algorithm.
223
- * @public
261
+ * Static constructor for a {@link Experimental.RangeOf | RangeOf<T>}.
262
+ * @param init - {@link Experimental.RangeOfProperties | Range initializer}.
263
+ * @returns A new {@link Experimental.RangeOf | RangeOf<T>}.
224
264
  */
225
- declare class Md5Normalizer extends Hash_2.HashingNormalizer {
226
- constructor();
227
- static md5Hash(parts: string[]): string;
228
- }
229
-
265
+ static createRange<T>(init?: RangeOfProperties<T>): Result<RangeOf<T>>;
230
266
  /**
231
- * Reads a record-jar from an array of strings, each of which represents one
232
- * line in the source file.
233
- * @param lines - the array of strings to be parsed
234
- * @param options - Optional parser configuration
235
- * @returns a corresponding array of `Record<string, string>`
236
- * @public
267
+ * Gets a formatted description of a {@link Experimental.RangeOfProperties | RangeOfProperties<T>} given an
268
+ * optional set of formats and 'empty' value to use.
269
+ * @param range - The {@link Experimental.RangeOfProperties | RangeOfProperties<T>} to be formatted.
270
+ * @param formats - Optional {@link Experimental.RangeOfFormats | formats} to use. Default is
271
+ * {@link Experimental.DEFAULT_RANGEOF_FORMATS | DEFAULT_RANGEOF_FORMATS}.
272
+ * @param emptyValue - Value which represents unbounded minimum or maximum for this range. Default is `undefined`.
273
+ * @returns A string representation of the range.
237
274
  */
238
- declare function parseRecordJarLines(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]>;
239
-
275
+ static propertiesToString<T>(range: RangeOfProperties<T>, formats?: RangeOfFormats, emptyValue?: T): string | undefined;
240
276
  /**
241
- * Simple implementation of a possibly open-ended range of some comparable
242
- * type `<T>` with test and formatting.
243
- * @public
277
+ * Default comparison uses javascript built-in comparison.
278
+ * @param t1 - First value to be compared.
279
+ * @param t2 - Second value to be compared.
280
+ * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger
281
+ * and `'equal'` if `t1` and `t2` are equal.
282
+ * @internal
244
283
  */
245
- declare class RangeOf<T> implements RangeOfProperties<T> {
246
- /**
247
- * Minimum extent of the range.
248
- */
249
- readonly min?: T;
250
- /**
251
- * Maximum extent of the range.
252
- */
253
- readonly max?: T;
254
- /**
255
- * Creates a new {@link Experimental.RangeOf | RangeOf<T>}.
256
- * @param min - Optional minimum extent of the range.
257
- * @param max - Optional maximum extent of the range.
258
- */
259
- constructor(min?: T, max?: T);
260
- /**
261
- * Static constructor for a {@link Experimental.RangeOf | RangeOf<T>}.
262
- * @param init - {@link Experimental.RangeOfProperties | Range initializer}.
263
- * @returns A new {@link Experimental.RangeOf | RangeOf<T>}.
264
- */
265
- static createRange<T>(init?: RangeOfProperties<T>): Result<RangeOf<T>>;
266
- /**
267
- * Gets a formatted description of a {@link Experimental.RangeOfProperties | RangeOfProperties<T>} given an
268
- * optional set of formats and 'empty' value to use.
269
- * @param range - The {@link Experimental.RangeOfProperties | RangeOfProperties<T>} to be formatted.
270
- * @param formats - Optional {@link Experimental.RangeOfFormats | formats} to use. Default is
271
- * {@link Experimental.DEFAULT_RANGEOF_FORMATS | DEFAULT_RANGEOF_FORMATS}.
272
- * @param emptyValue - Value which represents unbounded minimum or maximum for this range. Default is `undefined`.
273
- * @returns A string representation of the range.
274
- */
275
- static propertiesToString<T>(range: RangeOfProperties<T>, formats?: RangeOfFormats, emptyValue?: T): string | undefined;
276
- /**
277
- * Default comparison uses javascript built-in comparison.
278
- * @param t1 - First value to be compared.
279
- * @param t2 - Second value to be compared.
280
- * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger
281
- * and `'equal'` if `t1` and `t2` are equal.
282
- * @internal
283
- */
284
- protected static _defaultCompare<T>(t1: T, t2: T): 'less' | 'equal' | 'greater';
285
- /**
286
- * Checks if a supplied value is within this range.
287
- * @param t - The value to be tested.
288
- * @returns `'included'` if `t` falls within the range, `'less'` if `t` falls
289
- * below the minimum extent of the range and `'greater'` if `t` is above the
290
- * maximum extent.
291
- */
292
- check(t: T): 'less' | 'included' | 'greater';
293
- /**
294
- * Determines if a supplied value is within this range.
295
- * @param t - The value to be tested.
296
- * @returns Returns `true` if `t` falls within the range, `false` otherwise.
297
- */
298
- includes(t: T): boolean;
299
- /**
300
- * Finds the transition value that would bring a supplied value `t` into
301
- * range.
302
- * @param t - The value to be tested.
303
- * @returns The minimum extent of the range if `t` is below the range or
304
- * the maximum extent of the range if `t` is above the range. Returns
305
- * `undefined` if `t` already falls within the range.
306
- */
307
- findTransition(t: T): T | undefined;
308
- /**
309
- * Formats the minimum and maximum values of this range.
310
- * @param format - A format function used to format the values.
311
- * @returns A {@link Experimental.RangeOfProperties | RangeOfProperties<string>} containing the
312
- * formatted representation of the {@link Experimental.RangeOf.min | minimum} and
313
- * {@link Experimental.RangeOf.max | maximum}
314
- * extent of the range, or `undefined` for an extent that is not present.
315
- */
316
- toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties<string>;
317
- /**
318
- * Formats this range using the supplied format function.
319
- * @param format - Format function used to format minimum and maximum extent values.
320
- * @param formats - The {@link Experimental.RangeOfFormats | format strings} used to format the range
321
- * (default {@link Experimental.DEFAULT_RANGEOF_FORMATS}).
322
- * @returns Returns a formatted representation of this range.
323
- */
324
- format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined;
325
- /**
326
- * Inner compare method can be overridden by a derived class.
327
- * @param t1 - First value to compare.
328
- * @param t2 - Second value to compare.
329
- * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger
330
- * and `'equal'` if `t1` and `t2` are equal.
331
- * @internal
332
- */
333
- protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater';
334
- }
335
-
284
+ protected static _defaultCompare<T>(t1: T, t2: T): 'less' | 'equal' | 'greater';
336
285
  /**
337
- * A helper wrapper to construct a {@link Converter} which converts to {@link Experimental.RangeOf | RangeOf<T>}
338
- * where `<T>` is some comparable type.
339
- * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.
340
- * @public
286
+ * Checks if a supplied value is within this range.
287
+ * @param t - The value to be tested.
288
+ * @returns `'included'` if `t` falls within the range, `'less'` if `t` falls
289
+ * below the minimum extent of the range and `'greater'` if `t` is above the
290
+ * maximum extent.
341
291
  */
342
- declare function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC>;
343
-
292
+ check(t: T): 'less' | 'included' | 'greater';
344
293
  /**
345
- * Format strings (in mustache format) to
346
- * use for both open-ended and complete
347
- * {@link Experimental.RangeOf | RangeOf<T>}.
348
- * @public
294
+ * Determines if a supplied value is within this range.
295
+ * @param t - The value to be tested.
296
+ * @returns Returns `true` if `t` falls within the range, `false` otherwise.
349
297
  */
350
- declare interface RangeOfFormats {
351
- minOnly: string;
352
- maxOnly: string;
353
- minMax: string;
354
- }
355
-
298
+ includes(t: T): boolean;
356
299
  /**
357
- * Represents a generic range of some comparable type `<T>`.
358
- * @public
300
+ * Finds the transition value that would bring a supplied value `t` into
301
+ * range.
302
+ * @param t - The value to be tested.
303
+ * @returns The minimum extent of the range if `t` is below the range or
304
+ * the maximum extent of the range if `t` is above the range. Returns
305
+ * `undefined` if `t` already falls within the range.
359
306
  */
360
- declare interface RangeOfProperties<T> {
361
- readonly min?: T;
362
- readonly max?: T;
363
- }
364
-
307
+ findTransition(t: T): T | undefined;
365
308
  /**
366
- * A helper wrapper to construct a {@link Converter} which converts to an arbitrary strongly-typed
367
- * range of some comparable type.
368
- * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.
369
- * @param constructor - Static constructor to instantiate the object.
370
- * @public
309
+ * Formats the minimum and maximum values of this range.
310
+ * @param format - A format function used to format the values.
311
+ * @returns A {@link Experimental.RangeOfProperties | RangeOfProperties<string>} containing the
312
+ * formatted representation of the {@link Experimental.RangeOf.min | minimum} and
313
+ * {@link Experimental.RangeOf.max | maximum}
314
+ * extent of the range, or `undefined` for an extent that is not present.
371
315
  */
372
- declare function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(converter: Converter<T, TC>, constructor: (init: RangeOfProperties<T>) => Result<RT>): Converter<RT, TC>;
373
-
316
+ toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties<string>;
374
317
  /**
375
- * Reads a CSV file from a supplied path.
376
- * @param srcPath - Source path from which the file is read.
377
- * @param options - optional parameters to control the processing
378
- * @returns The contents of the file.
379
- * @beta
318
+ * Formats this range using the supplied format function.
319
+ * @param format - Format function used to format minimum and maximum extent values.
320
+ * @param formats - The {@link Experimental.RangeOfFormats | format strings} used to format the range
321
+ * (default {@link Experimental.DEFAULT_RANGEOF_FORMATS}).
322
+ * @returns Returns a formatted representation of this range.
380
323
  */
381
- declare function readCsvFileSync(srcPath: string, options?: CsvOptions): Result<unknown>;
382
-
324
+ format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined;
383
325
  /**
384
- * Reads a record-jar file from a supplied path.
385
- * @param srcPath - Source path from which the file is read.
386
- * @param options - Optional parser configuration
387
- * @returns The contents of the file as an array of `Record<string, string>`
388
- * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01
389
- * @public
326
+ * Inner compare method can be overridden by a derived class.
327
+ * @param t1 - First value to compare.
328
+ * @param t2 - Second value to compare.
329
+ * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger
330
+ * and `'equal'` if `t1` and `t2` are equal.
331
+ * @internal
390
332
  */
391
- declare function readRecordJarFileSync(srcPath: string, options?: JarRecordParserOptions): Result<JarRecord[]>;
333
+ protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater';
334
+ }
335
+
336
+ /**
337
+ * A helper wrapper to construct a `Converter` which converts to {@link Experimental.RangeOf | RangeOf<T>}
338
+ * where `<T>` is some comparable type.
339
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
340
+ * @public
341
+ */
342
+ declare function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC>;
392
343
 
393
- declare namespace RecordJar {
394
- export {
395
- parseRecordJarLines,
396
- readRecordJarFileSync,
397
- JarRecord,
398
- JarFieldPicker,
399
- JarRecordParserOptions
400
- }
344
+ /**
345
+ * Format strings (in mustache format) to
346
+ * use for both open-ended and complete
347
+ * {@link Experimental.RangeOf | RangeOf<T>}.
348
+ * @public
349
+ */
350
+ declare interface RangeOfFormats {
351
+ minOnly: string;
352
+ maxOnly: string;
353
+ minMax: string;
354
+ }
355
+
356
+ /**
357
+ * Represents a generic range of some comparable type `<T>`.
358
+ * @public
359
+ */
360
+ declare interface RangeOfProperties<T> {
361
+ readonly min?: T;
362
+ readonly max?: T;
363
+ }
364
+
365
+ /**
366
+ * A helper wrapper to construct a `Converter` which converts to an arbitrary strongly-typed
367
+ * range of some comparable type.
368
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
369
+ * @param constructor - Static constructor to instantiate the object.
370
+ * @public
371
+ */
372
+ declare function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(converter: Converter<T, TC>, constructor: (init: RangeOfProperties<T>) => Result<RT>): Converter<RT, TC>;
373
+
374
+ /**
375
+ * Reads a CSV file from a supplied path.
376
+ * @param srcPath - Source path from which the file is read.
377
+ * @param options - optional parameters to control the processing
378
+ * @returns The contents of the file.
379
+ * @beta
380
+ */
381
+ declare function readCsvFileSync(srcPath: string, options?: CsvOptions): Result<unknown>;
382
+
383
+ /**
384
+ * Reads a record-jar file from a supplied path.
385
+ * @param srcPath - Source path from which the file is read.
386
+ * @param options - Optional parser configuration
387
+ * @returns The contents of the file as an array of `Record<string, string>`
388
+ * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01
389
+ * @public
390
+ */
391
+ declare function readRecordJarFileSync(srcPath: string, options?: JarRecordParserOptions): Result<JarRecord[]>;
392
+
393
+ declare namespace RecordJar {
394
+ export {
395
+ parseRecordJarLines,
396
+ readRecordJarFileSync,
397
+ JarRecord,
398
+ JarFieldPicker,
399
+ JarRecordParserOptions
401
400
  }
402
- export { RecordJar }
401
+ }
402
+ export { RecordJar }
403
403
 
404
- export { }
404
+ export { }
@@ -1,27 +1,27 @@
1
1
  import { Converter, Converters, Result } from '@fgv/ts-utils';
2
2
  import { ExtendedArray, RangeOf, RangeOfProperties } from '../experimental';
3
3
  /**
4
- * A helper function to create a {@link Converter} which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
4
+ * A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
5
5
  * @remarks
6
6
  * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot
7
7
  * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.
8
- * @param converter - {@link Converter} used to convert each item in the array
8
+ * @param converter - `Converter` used to convert each item in the array
9
9
  * @param ignoreErrors - Specifies treatment of unconvertible elements
10
10
  * @beta
11
11
  */
12
12
  export declare function extendedArrayOf<T, TC = undefined>(label: string, converter: Converter<T, TC>, onError?: Converters.OnError): Converter<ExtendedArray<T>, TC>;
13
13
  /**
14
- * A helper wrapper to construct a {@link Converter} which converts to an arbitrary strongly-typed
14
+ * A helper wrapper to construct a `Converter` which converts to an arbitrary strongly-typed
15
15
  * range of some comparable type.
16
- * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.
16
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
17
17
  * @param constructor - Static constructor to instantiate the object.
18
18
  * @public
19
19
  */
20
20
  export declare function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(converter: Converter<T, TC>, constructor: (init: RangeOfProperties<T>) => Result<RT>): Converter<RT, TC>;
21
21
  /**
22
- * A helper wrapper to construct a {@link Converter} which converts to {@link Experimental.RangeOf | RangeOf<T>}
22
+ * A helper wrapper to construct a `Converter` which converts to {@link Experimental.RangeOf | RangeOf<T>}
23
23
  * where `<T>` is some comparable type.
24
- * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.
24
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
25
25
  * @public
26
26
  */
27
27
  export declare function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC>;
@@ -25,11 +25,11 @@ exports.rangeOf = exports.rangeTypeOf = exports.extendedArrayOf = void 0;
25
25
  const ts_utils_1 = require("@fgv/ts-utils");
26
26
  const experimental_1 = require("../experimental");
27
27
  /**
28
- * A helper function to create a {@link Converter} which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
28
+ * A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
29
29
  * @remarks
30
30
  * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot
31
31
  * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.
32
- * @param converter - {@link Converter} used to convert each item in the array
32
+ * @param converter - `Converter` used to convert each item in the array
33
33
  * @param ignoreErrors - Specifies treatment of unconvertible elements
34
34
  * @beta
35
35
  */
@@ -40,9 +40,9 @@ function extendedArrayOf(label, converter, onError = 'failOnError') {
40
40
  }
41
41
  exports.extendedArrayOf = extendedArrayOf;
42
42
  /**
43
- * A helper wrapper to construct a {@link Converter} which converts to an arbitrary strongly-typed
43
+ * A helper wrapper to construct a `Converter` which converts to an arbitrary strongly-typed
44
44
  * range of some comparable type.
45
- * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.
45
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
46
46
  * @param constructor - Static constructor to instantiate the object.
47
47
  * @public
48
48
  */
@@ -60,9 +60,9 @@ function rangeTypeOf(converter, constructor) {
60
60
  }
61
61
  exports.rangeTypeOf = rangeTypeOf;
62
62
  /**
63
- * A helper wrapper to construct a {@link Converter} which converts to {@link Experimental.RangeOf | RangeOf<T>}
63
+ * A helper wrapper to construct a `Converter` which converts to {@link Experimental.RangeOf | RangeOf<T>}
64
64
  * where `<T>` is some comparable type.
65
- * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.
65
+ * @param converter - `Converter` used to convert `min` and `max` extent of the range.
66
66
  * @public
67
67
  */
68
68
  function rangeOf(converter) {
@@ -1 +1 @@
1
- {"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../src/packlets/conversion/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAA+F;AAC/F,kDAA4E;AAE5E;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,KAAa,EACb,SAA2B,EAC3B,UAA8B,aAAa;IAE3C,OAAO,qBAAU,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;QAC/D,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,4BAAa,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC;AARD,0CAQC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CACzB,SAA2B,EAC3B,WAAuD;IAEvD,OAAO,IAAI,qBAAU,CAAC,aAAa,CAAC,CAAC,IAAa,EAAE,MAAM,EAAE,OAAY,EAAE,EAAE;QAC1E,MAAM,MAAM,GAAG,qBAAU,CAAC,MAAM,CAC9B;YACE,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;SACf,EACD,EAAE,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CACnC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzB,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,OAAO,WAAW,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,kCAiBC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAkB,SAA2B;IAClE,OAAO,WAAW,CAAoB,SAAS,EAAE,sBAAO,CAAC,WAAW,CAAC,CAAC;AACxE,CAAC;AAFD,0BAEC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Conversion, Converter, Converters, Result, captureResult, fail } from '@fgv/ts-utils';\nimport { ExtendedArray, RangeOf, RangeOfProperties } from '../experimental';\n\n/**\n * A helper function to create a {@link Converter} which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.\n * @remarks\n * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot\n * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.\n * @param converter - {@link Converter} used to convert each item in the array\n * @param ignoreErrors - Specifies treatment of unconvertible elements\n * @beta\n */\nexport function extendedArrayOf<T, TC = undefined>(\n label: string,\n converter: Converter<T, TC>,\n onError: Converters.OnError = 'failOnError'\n): Converter<ExtendedArray<T>, TC> {\n return Converters.arrayOf(converter, onError).map((items: T[]) => {\n return captureResult(() => new ExtendedArray(label, ...items));\n });\n}\n\n/**\n * A helper wrapper to construct a {@link Converter} which converts to an arbitrary strongly-typed\n * range of some comparable type.\n * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.\n * @param constructor - Static constructor to instantiate the object.\n * @public\n */\nexport function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(\n converter: Converter<T, TC>,\n constructor: (init: RangeOfProperties<T>) => Result<RT>\n): Converter<RT, TC> {\n return new Conversion.BaseConverter((from: unknown, __self, context?: TC) => {\n const result = Converters.object(\n {\n min: converter,\n max: converter\n },\n { optionalFields: ['min', 'max'] }\n ).convert(from, context);\n if (result.isSuccess()) {\n return constructor({ min: result.value.min, max: result.value.max });\n }\n return fail(result.message);\n });\n}\n\n/**\n * A helper wrapper to construct a {@link Converter} which converts to {@link Experimental.RangeOf | RangeOf<T>}\n * where `<T>` is some comparable type.\n * @param converter - {@link Converter} used to convert `min` and `max` extent of the range.\n * @public\n */\nexport function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC> {\n return rangeTypeOf<T, RangeOf<T>, TC>(converter, RangeOf.createRange);\n}\n"]}
1
+ {"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../src/packlets/conversion/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAA+F;AAC/F,kDAA4E;AAE5E;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,KAAa,EACb,SAA2B,EAC3B,UAA8B,aAAa;IAE3C,OAAO,qBAAU,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;QAC/D,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,4BAAa,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC;AARD,0CAQC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CACzB,SAA2B,EAC3B,WAAuD;IAEvD,OAAO,IAAI,qBAAU,CAAC,aAAa,CAAC,CAAC,IAAa,EAAE,MAAM,EAAE,OAAY,EAAE,EAAE;QAC1E,MAAM,MAAM,GAAG,qBAAU,CAAC,MAAM,CAC9B;YACE,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,SAAS;SACf,EACD,EAAE,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CACnC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzB,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,OAAO,WAAW,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,kCAiBC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAkB,SAA2B;IAClE,OAAO,WAAW,CAAoB,SAAS,EAAE,sBAAO,CAAC,WAAW,CAAC,CAAC;AACxE,CAAC;AAFD,0BAEC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Conversion, Converter, Converters, Result, captureResult, fail } from '@fgv/ts-utils';\nimport { ExtendedArray, RangeOf, RangeOfProperties } from '../experimental';\n\n/**\n * A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.\n * @remarks\n * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot\n * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.\n * @param converter - `Converter` used to convert each item in the array\n * @param ignoreErrors - Specifies treatment of unconvertible elements\n * @beta\n */\nexport function extendedArrayOf<T, TC = undefined>(\n label: string,\n converter: Converter<T, TC>,\n onError: Converters.OnError = 'failOnError'\n): Converter<ExtendedArray<T>, TC> {\n return Converters.arrayOf(converter, onError).map((items: T[]) => {\n return captureResult(() => new ExtendedArray(label, ...items));\n });\n}\n\n/**\n * A helper wrapper to construct a `Converter` which converts to an arbitrary strongly-typed\n * range of some comparable type.\n * @param converter - `Converter` used to convert `min` and `max` extent of the range.\n * @param constructor - Static constructor to instantiate the object.\n * @public\n */\nexport function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(\n converter: Converter<T, TC>,\n constructor: (init: RangeOfProperties<T>) => Result<RT>\n): Converter<RT, TC> {\n return new Conversion.BaseConverter((from: unknown, __self, context?: TC) => {\n const result = Converters.object(\n {\n min: converter,\n max: converter\n },\n { optionalFields: ['min', 'max'] }\n ).convert(from, context);\n if (result.isSuccess()) {\n return constructor({ min: result.value.min, max: result.value.max });\n }\n return fail(result.message);\n });\n}\n\n/**\n * A helper wrapper to construct a `Converter` which converts to {@link Experimental.RangeOf | RangeOf<T>}\n * where `<T>` is some comparable type.\n * @param converter - `Converter` used to convert `min` and `max` extent of the range.\n * @public\n */\nexport function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC> {\n return rangeTypeOf<T, RangeOf<T>, TC>(converter, RangeOf.createRange);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  /**
3
- * Options for {@link Csv.readCsvFileSync}
3
+ * Options for {@link Csv.readCsvFileSync | readCsvFileSync}
4
4
  * @beta
5
5
  */
6
6
  export interface CsvOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"csvHelpers.js","sourceRoot":"","sources":["../../../src/packlets/csv/csvHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAsD;AACtD,uCAAyB;AACzB,yCAAkC;AAClC,2CAA6B;AAW7B;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,OAAoB;IACnE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1D,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;QACxB,2BAA2B;QAC3B,OAAO,IAAA,iBAAK,EAAC,IAAI,kBACf,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAClC,MAAM,EAAE,KAAK,EACb,aAAa,EAAE,KAAK,EACpB,cAAc,EAAE,QAAQ,IACrB,OAAO,EACV,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,0CAcC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport * as fs from 'fs';\nimport { parse } from 'papaparse';\nimport * as path from 'path';\n\n/**\n * Options for {@link Csv.readCsvFileSync}\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface CsvOptions {\n delimiter?: string;\n}\n\n/**\n * Reads a CSV file from a supplied path.\n * @param srcPath - Source path from which the file is read.\n * @param options - optional parameters to control the processing\n * @returns The contents of the file.\n * @beta\n */\nexport function readCsvFileSync(srcPath: string, options?: CsvOptions): Result<unknown> {\n return captureResult(() => {\n const fullPath = path.resolve(srcPath);\n const body = fs.readFileSync(fullPath, 'utf8').toString();\n options = options ?? {};\n // eslint-disable-next-line\n return parse(body, {\n transform: (s: string) => s.trim(),\n header: false,\n dynamicTyping: false,\n skipEmptyLines: 'greedy',\n ...options\n }).data.slice(1);\n });\n}\n"]}
1
+ {"version":3,"file":"csvHelpers.js","sourceRoot":"","sources":["../../../src/packlets/csv/csvHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAsD;AACtD,uCAAyB;AACzB,yCAAkC;AAClC,2CAA6B;AAW7B;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,OAAoB;IACnE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1D,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;QACxB,2BAA2B;QAC3B,OAAO,IAAA,iBAAK,EAAC,IAAI,kBACf,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAClC,MAAM,EAAE,KAAK,EACb,aAAa,EAAE,KAAK,EACpB,cAAc,EAAE,QAAQ,IACrB,OAAO,EACV,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,0CAcC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport * as fs from 'fs';\nimport { parse } from 'papaparse';\nimport * as path from 'path';\n\n/**\n * Options for {@link Csv.readCsvFileSync | readCsvFileSync}\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface CsvOptions {\n delimiter?: string;\n}\n\n/**\n * Reads a CSV file from a supplied path.\n * @param srcPath - Source path from which the file is read.\n * @param options - optional parameters to control the processing\n * @returns The contents of the file.\n * @beta\n */\nexport function readCsvFileSync(srcPath: string, options?: CsvOptions): Result<unknown> {\n return captureResult(() => {\n const fullPath = path.resolve(srcPath);\n const body = fs.readFileSync(fullPath, 'utf8').toString();\n options = options ?? {};\n // eslint-disable-next-line\n return parse(body, {\n transform: (s: string) => s.trim(),\n header: false,\n dynamicTyping: false,\n skipEmptyLines: 'greedy',\n ...options\n }).data.slice(1);\n });\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  /**
3
3
  * An experimental array template which extend built-in `Array` to include a handful
4
- * of predicates which return {@link Result | Result<T>}.
4
+ * of predicates which return `Result<T>`.
5
5
  * @beta
6
6
  */
7
7
  export declare class ExtendedArray<T> extends Array<T> {
8
8
  readonly itemDescription: string;
9
9
  /**
10
- * Constructs an {@link Experimental.ExtendedArray}.
10
+ * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.
11
11
  * @param itemDescription - Brief description of the type of each item in this array.
12
12
  * @param items - The initial contents of the array.
13
13
  */
@@ -16,7 +16,7 @@ export declare class ExtendedArray<T> extends Array<T> {
16
16
  * Type guard to determine if some arbitrary array is an
17
17
  * {@link Experimental.ExtendedArray}
18
18
  * @param a - The `Array` to be tested.
19
- * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray},
19
+ * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},
20
20
  * `false` otherwise.
21
21
  */
22
22
  static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T>;
@@ -24,31 +24,31 @@ export declare class ExtendedArray<T> extends Array<T> {
24
24
  * Determines if this array contains exactly one element which matches
25
25
  * a supplied predicate.
26
26
  * @param predicate - The predicate function to be applied.
27
- * @returns Returns {@link Success | Success<T>} with the single matching
28
- * result if exactly one item matches `predicate`. Returns {@link Failure}
27
+ * @returns Returns `Success<T>` with the single matching
28
+ * result if exactly one item matches `predicate`. Returns `Failure<T>`
29
29
  * with an error message if there are no matches or more than one match.
30
30
  */
31
31
  single(predicate?: (item: T) => boolean): Result<T>;
32
32
  /**
33
- * Returns the first element of an {@link Experimental.ExtendedArray}. Fails with an
33
+ * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an
34
34
  * error message if the array is empty.
35
35
  * @param failMessage - Optional message to be displayed in the event of failure.
36
- * @returns Returns {@link Success | Success<T>} with the value of the first element
37
- * in the array, or {@link Failure} with an error message if the array is empty.
36
+ * @returns Returns `Success<T>` with the value of the first element
37
+ * in the array, or `Failure<T>` with an error message if the array is empty.
38
38
  */
39
39
  first(failMessage?: string): Result<T>;
40
40
  /**
41
- * Returns an array containing all elements of an {@link Experimental.ExtendedArray}. Fails with
42
- * an error message if the array is empty.
41
+ * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.
42
+ * Fails with an error message if the array is empty.
43
43
  * @param failMessage - Optional message to be displayed in the event of failure.
44
- * @returns Returns {@link Success | Success<T[]>} with a new (non-extended) `Array`
45
- * containing the elements of this array, or {@link Failure} with an error message
44
+ * @returns Returns `Success<T>` with a new (non-extended) `Array`
45
+ * containing the elements of this array, or `Failure<T>` with an error message
46
46
  * if the array is empty.
47
47
  */
48
48
  atLeastOne(failMessage?: string): Result<T[]>;
49
49
  /**
50
50
  * Gets a new (non-extended) `Array` containing all of the elements from this
51
- * {@link Experimental.ExtendedArray}.
51
+ * {@link Experimental.ExtendedArray | ExtendedArray}.
52
52
  * @returns A new (non-extended) `Array<T>`.
53
53
  */
54
54
  all(): T[];
@@ -25,12 +25,12 @@ exports.ExtendedArray = void 0;
25
25
  const ts_utils_1 = require("@fgv/ts-utils");
26
26
  /**
27
27
  * An experimental array template which extend built-in `Array` to include a handful
28
- * of predicates which return {@link Result | Result<T>}.
28
+ * of predicates which return `Result<T>`.
29
29
  * @beta
30
30
  */
31
31
  class ExtendedArray extends Array {
32
32
  /**
33
- * Constructs an {@link Experimental.ExtendedArray}.
33
+ * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.
34
34
  * @param itemDescription - Brief description of the type of each item in this array.
35
35
  * @param items - The initial contents of the array.
36
36
  */
@@ -42,7 +42,7 @@ class ExtendedArray extends Array {
42
42
  * Type guard to determine if some arbitrary array is an
43
43
  * {@link Experimental.ExtendedArray}
44
44
  * @param a - The `Array` to be tested.
45
- * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray},
45
+ * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},
46
46
  * `false` otherwise.
47
47
  */
48
48
  static isExtendedArray(a) {
@@ -52,8 +52,8 @@ class ExtendedArray extends Array {
52
52
  * Determines if this array contains exactly one element which matches
53
53
  * a supplied predicate.
54
54
  * @param predicate - The predicate function to be applied.
55
- * @returns Returns {@link Success | Success<T>} with the single matching
56
- * result if exactly one item matches `predicate`. Returns {@link Failure}
55
+ * @returns Returns `Success<T>` with the single matching
56
+ * result if exactly one item matches `predicate`. Returns `Failure<T>`
57
57
  * with an error message if there are no matches or more than one match.
58
58
  */
59
59
  single(predicate) {
@@ -67,11 +67,11 @@ class ExtendedArray extends Array {
67
67
  return (0, ts_utils_1.fail)(`${this.itemDescription} matches ${match.length} items`);
68
68
  }
69
69
  /**
70
- * Returns the first element of an {@link Experimental.ExtendedArray}. Fails with an
70
+ * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an
71
71
  * error message if the array is empty.
72
72
  * @param failMessage - Optional message to be displayed in the event of failure.
73
- * @returns Returns {@link Success | Success<T>} with the value of the first element
74
- * in the array, or {@link Failure} with an error message if the array is empty.
73
+ * @returns Returns `Success<T>` with the value of the first element
74
+ * in the array, or `Failure<T>` with an error message if the array is empty.
75
75
  */
76
76
  first(failMessage) {
77
77
  if (this.length > 0) {
@@ -80,11 +80,11 @@ class ExtendedArray extends Array {
80
80
  return (0, ts_utils_1.fail)(failMessage !== null && failMessage !== void 0 ? failMessage : `${this.itemDescription} not found`);
81
81
  }
82
82
  /**
83
- * Returns an array containing all elements of an {@link Experimental.ExtendedArray}. Fails with
84
- * an error message if the array is empty.
83
+ * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.
84
+ * Fails with an error message if the array is empty.
85
85
  * @param failMessage - Optional message to be displayed in the event of failure.
86
- * @returns Returns {@link Success | Success<T[]>} with a new (non-extended) `Array`
87
- * containing the elements of this array, or {@link Failure} with an error message
86
+ * @returns Returns `Success<T>` with a new (non-extended) `Array`
87
+ * containing the elements of this array, or `Failure<T>` with an error message
88
88
  * if the array is empty.
89
89
  */
90
90
  atLeastOne(failMessage) {
@@ -95,7 +95,7 @@ class ExtendedArray extends Array {
95
95
  }
96
96
  /**
97
97
  * Gets a new (non-extended) `Array` containing all of the elements from this
98
- * {@link Experimental.ExtendedArray}.
98
+ * {@link Experimental.ExtendedArray | ExtendedArray}.
99
99
  * @returns A new (non-extended) `Array<T>`.
100
100
  */
101
101
  all() {
@@ -1 +1 @@
1
- {"version":3,"file":"extendedArray.js","sourceRoot":"","sources":["../../../src/packlets/experimental/extendedArray.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAEtD;;;;GAIG;AACH,MAAa,aAAiB,SAAQ,KAAQ;IAG5C;;;;OAIG;IACH,YAAmB,eAAuB,EAAE,GAAG,KAAU;QACvD,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;QAChB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,eAAe,CAAI,CAAO;QACtC,OAAO,CAAC,YAAY,aAAa,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,SAAgC;QAC5C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAA,kBAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,eAAe,YAAY,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,WAAoB;QAC/B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,WAAoB;QACpC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,IAAA,kBAAO,EAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,GAAG;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAhFD,sCAgFC","sourcesContent":["/*\r\n * Copyright (c) 2020 Erik Fortune\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in all\r\n * copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n * SOFTWARE.\r\n */\r\n\r\nimport { Result, fail, succeed } from '@fgv/ts-utils';\r\n\r\n/**\r\n * An experimental array template which extend built-in `Array` to include a handful\r\n * of predicates which return {@link Result | Result<T>}.\r\n * @beta\r\n */\r\nexport class ExtendedArray<T> extends Array<T> {\r\n public readonly itemDescription: string;\r\n\r\n /**\r\n * Constructs an {@link Experimental.ExtendedArray}.\r\n * @param itemDescription - Brief description of the type of each item in this array.\r\n * @param items - The initial contents of the array.\r\n */\r\n public constructor(itemDescription: string, ...items: T[]) {\r\n super(...items);\r\n this.itemDescription = itemDescription;\r\n }\r\n\r\n /**\r\n * Type guard to determine if some arbitrary array is an\r\n * {@link Experimental.ExtendedArray}\r\n * @param a - The `Array` to be tested.\r\n * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray},\r\n * `false` otherwise.\r\n */\r\n public static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T> {\r\n return a instanceof ExtendedArray;\r\n }\r\n\r\n /**\r\n * Determines if this array contains exactly one element which matches\r\n * a supplied predicate.\r\n * @param predicate - The predicate function to be applied.\r\n * @returns Returns {@link Success | Success<T>} with the single matching\r\n * result if exactly one item matches `predicate`. Returns {@link Failure}\r\n * with an error message if there are no matches or more than one match.\r\n */\r\n public single(predicate?: (item: T) => boolean): Result<T> {\r\n const match = predicate ? this.filter(predicate) : this;\r\n if (match.length === 1) {\r\n return succeed(match[0]);\r\n }\r\n if (match.length === 0) {\r\n return fail(`${this.itemDescription} not found`);\r\n }\r\n return fail(`${this.itemDescription} matches ${match.length} items`);\r\n }\r\n\r\n /**\r\n * Returns the first element of an {@link Experimental.ExtendedArray}. Fails with an\r\n * error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns {@link Success | Success<T>} with the value of the first element\r\n * in the array, or {@link Failure} with an error message if the array is empty.\r\n */\r\n public first(failMessage?: string): Result<T> {\r\n if (this.length > 0) {\r\n return succeed(this[0]);\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Returns an array containing all elements of an {@link Experimental.ExtendedArray}. Fails with\r\n * an error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns {@link Success | Success<T[]>} with a new (non-extended) `Array`\r\n * containing the elements of this array, or {@link Failure} with an error message\r\n * if the array is empty.\r\n */\r\n public atLeastOne(failMessage?: string): Result<T[]> {\r\n if (this.length > 0) {\r\n return succeed(Array.from(this));\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Gets a new (non-extended) `Array` containing all of the elements from this\r\n * {@link Experimental.ExtendedArray}.\r\n * @returns A new (non-extended) `Array<T>`.\r\n */\r\n public all(): T[] {\r\n return Array.from(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"extendedArray.js","sourceRoot":"","sources":["../../../src/packlets/experimental/extendedArray.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAEtD;;;;GAIG;AACH,MAAa,aAAiB,SAAQ,KAAQ;IAG5C;;;;OAIG;IACH,YAAmB,eAAuB,EAAE,GAAG,KAAU;QACvD,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;QAChB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,eAAe,CAAI,CAAO;QACtC,OAAO,CAAC,YAAY,aAAa,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,SAAgC;QAC5C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAA,kBAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,eAAe,YAAY,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,WAAoB;QAC/B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,WAAoB;QACpC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,IAAA,kBAAO,EAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,GAAG;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAhFD,sCAgFC","sourcesContent":["/*\r\n * Copyright (c) 2020 Erik Fortune\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in all\r\n * copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n * SOFTWARE.\r\n */\r\n\r\nimport { Result, fail, succeed } from '@fgv/ts-utils';\r\n\r\n/**\r\n * An experimental array template which extend built-in `Array` to include a handful\r\n * of predicates which return `Result<T>`.\r\n * @beta\r\n */\r\nexport class ExtendedArray<T> extends Array<T> {\r\n public readonly itemDescription: string;\r\n\r\n /**\r\n * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @param itemDescription - Brief description of the type of each item in this array.\r\n * @param items - The initial contents of the array.\r\n */\r\n public constructor(itemDescription: string, ...items: T[]) {\r\n super(...items);\r\n this.itemDescription = itemDescription;\r\n }\r\n\r\n /**\r\n * Type guard to determine if some arbitrary array is an\r\n * {@link Experimental.ExtendedArray}\r\n * @param a - The `Array` to be tested.\r\n * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},\r\n * `false` otherwise.\r\n */\r\n public static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T> {\r\n return a instanceof ExtendedArray;\r\n }\r\n\r\n /**\r\n * Determines if this array contains exactly one element which matches\r\n * a supplied predicate.\r\n * @param predicate - The predicate function to be applied.\r\n * @returns Returns `Success<T>` with the single matching\r\n * result if exactly one item matches `predicate`. Returns `Failure<T>`\r\n * with an error message if there are no matches or more than one match.\r\n */\r\n public single(predicate?: (item: T) => boolean): Result<T> {\r\n const match = predicate ? this.filter(predicate) : this;\r\n if (match.length === 1) {\r\n return succeed(match[0]);\r\n }\r\n if (match.length === 0) {\r\n return fail(`${this.itemDescription} not found`);\r\n }\r\n return fail(`${this.itemDescription} matches ${match.length} items`);\r\n }\r\n\r\n /**\r\n * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an\r\n * error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with the value of the first element\r\n * in the array, or `Failure<T>` with an error message if the array is empty.\r\n */\r\n public first(failMessage?: string): Result<T> {\r\n if (this.length > 0) {\r\n return succeed(this[0]);\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * Fails with an error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with a new (non-extended) `Array`\r\n * containing the elements of this array, or `Failure<T>` with an error message\r\n * if the array is empty.\r\n */\r\n public atLeastOne(failMessage?: string): Result<T[]> {\r\n if (this.length > 0) {\r\n return succeed(Array.from(this));\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Gets a new (non-extended) `Array` containing all of the elements from this\r\n * {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @returns A new (non-extended) `Array<T>`.\r\n */\r\n public all(): T[] {\r\n return Array.from(this);\r\n }\r\n}\r\n"]}
@@ -12,7 +12,7 @@ export interface Formattable {
12
12
  /**
13
13
  * Formats an object using the supplied mustache template.
14
14
  * @param format - A mustache template used to format the object.
15
- * @returns {@link Success} with the resulting string, or {@link Failure}
15
+ * @returns `Success<string>` with the resulting string, or `Failure<string>`
16
16
  * with an error message if an error occurs.
17
17
  */
18
18
  format(format: string): Result<string>;
@@ -37,7 +37,7 @@ export declare class FormattableBase {
37
37
  }
38
38
  /**
39
39
  * Type definition for a formatting function, which takes a `string` and an
40
- * item and returns {@link Result | Result<string>}.
40
+ * item and returns `Result<string>`.
41
41
  * @beta
42
42
  */
43
43
  export type Formatter<T> = (format: string, item: T) => Result<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/packlets/experimental/formatter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;AAEH,4CAA2E;AAC3E,wDAAgC;AAEhC,kBAAQ,CAAC,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC;AAuBnC;;;GAGG;AACH,MAAa,eAAe;IAC1B;;;;;;OAMG;IACO,MAAM,CAAC,aAAa,CAAC,OAAiB,EAAE,KAAa,EAAE,KAAyB;QACxF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,KAAK,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgB;QAC5B,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,kBAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AArBD,0CAqBC;AAsBD;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAI,MAAc,EAAE,KAAU,EAAE,aAA2B;IACnF,OAAO,IAAA,qBAAU,EACf,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CACH,CAAC,SAAS,CAAC,CAAC,OAAiB,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AATD,gCASC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, mapResults, succeed } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\nMustache.escape = (s: string) => s;\n\n/**\n * Destination format for some formatted string.\n * @beta\n */\nexport type FormatTargets = 'text' | 'markdown' | 'embed';\n\n/**\n * Interface for an object that can be formatted.\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface Formattable {\n /**\n * Formats an object using the supplied mustache template.\n * @param format - A mustache template used to format the object.\n * @returns {@link Success} with the resulting string, or {@link Failure}\n * with an error message if an error occurs.\n */\n format(format: string): Result<string>;\n}\n\n/**\n * Base class which adds common formatting.\n * @beta\n */\nexport class FormattableBase {\n /**\n * Helper enables derived classes to add named details to a formatted presentation.\n * @param details - An array of detail description strings.\n * @param label - Label to use for the new detail.\n * @param value - Value to use for the new detail.\n * @internal\n */\n protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void {\n if (value !== undefined) {\n const padded = ` ${label}:`.padEnd(20, ' ');\n details.push(`${padded} ${value}`);\n }\n }\n\n /**\n * {@inheritdoc Experimental.Formattable.format}\n */\n public format(template: string): Result<string> {\n return captureResult(() => Mustache.render(template, this));\n }\n}\n\n/**\n * Type definition for a formatting function, which takes a `string` and an\n * item and returns {@link Result | Result<string>}.\n * @beta\n */\nexport type Formatter<T> = (format: string, item: T) => Result<string>;\n\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable\n * different format methods per output target.\n * @beta\n */\nexport type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by the\n * {@link Experimental.FormatTargets | default supported target formats}.\n * @beta\n */\nexport type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;\n\n/**\n * Formats a list of items using the supplied template and formatter, one result\n * per output line.\n * @param format - A mustache template used to format each item.\n * @param items - The items to be formatted.\n * @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.\n * @returns The resulting string.\n * @beta\n */\nexport function formatList<T>(format: string, items: T[], itemFormatter: Formatter<T>): Result<string> {\n return mapResults(\n items.map((item) => {\n return itemFormatter(format, item);\n })\n ).onSuccess((results: string[]) => {\n const filtered = results.filter((s) => s !== '');\n return succeed(filtered.join('\\n'));\n });\n}\n"]}
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/packlets/experimental/formatter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;AAEH,4CAA2E;AAC3E,wDAAgC;AAEhC,kBAAQ,CAAC,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC;AAuBnC;;;GAGG;AACH,MAAa,eAAe;IAC1B;;;;;;OAMG;IACO,MAAM,CAAC,aAAa,CAAC,OAAiB,EAAE,KAAa,EAAE,KAAyB;QACxF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,KAAK,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgB;QAC5B,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,kBAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AArBD,0CAqBC;AAsBD;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAI,MAAc,EAAE,KAAU,EAAE,aAA2B;IACnF,OAAO,IAAA,qBAAU,EACf,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CACH,CAAC,SAAS,CAAC,CAAC,OAAiB,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AATD,gCASC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, mapResults, succeed } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\nMustache.escape = (s: string) => s;\n\n/**\n * Destination format for some formatted string.\n * @beta\n */\nexport type FormatTargets = 'text' | 'markdown' | 'embed';\n\n/**\n * Interface for an object that can be formatted.\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface Formattable {\n /**\n * Formats an object using the supplied mustache template.\n * @param format - A mustache template used to format the object.\n * @returns `Success<string>` with the resulting string, or `Failure<string>`\n * with an error message if an error occurs.\n */\n format(format: string): Result<string>;\n}\n\n/**\n * Base class which adds common formatting.\n * @beta\n */\nexport class FormattableBase {\n /**\n * Helper enables derived classes to add named details to a formatted presentation.\n * @param details - An array of detail description strings.\n * @param label - Label to use for the new detail.\n * @param value - Value to use for the new detail.\n * @internal\n */\n protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void {\n if (value !== undefined) {\n const padded = ` ${label}:`.padEnd(20, ' ');\n details.push(`${padded} ${value}`);\n }\n }\n\n /**\n * {@inheritdoc Experimental.Formattable.format}\n */\n public format(template: string): Result<string> {\n return captureResult(() => Mustache.render(template, this));\n }\n}\n\n/**\n * Type definition for a formatting function, which takes a `string` and an\n * item and returns `Result<string>`.\n * @beta\n */\nexport type Formatter<T> = (format: string, item: T) => Result<string>;\n\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable\n * different format methods per output target.\n * @beta\n */\nexport type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by the\n * {@link Experimental.FormatTargets | default supported target formats}.\n * @beta\n */\nexport type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;\n\n/**\n * Formats a list of items using the supplied template and formatter, one result\n * per output line.\n * @param format - A mustache template used to format each item.\n * @param items - The items to be formatted.\n * @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.\n * @returns The resulting string.\n * @beta\n */\nexport function formatList<T>(format: string, items: T[], itemFormatter: Formatter<T>): Result<string> {\n return mapResults(\n items.map((item) => {\n return itemFormatter(format, item);\n })\n ).onSuccess((results: string[]) => {\n const filtered = results.filter((s) => s !== '');\n return succeed(filtered.join('\\n'));\n });\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Hash } from '@fgv/ts-utils';
2
2
  /**
3
- * A {@link Hash.HashingNormalizer | hashing normalizer} which computes object
3
+ * A hashing normalizer which computes object
4
4
  * hash using the MD5 algorithm.
5
5
  * @public
6
6
  */
@@ -48,7 +48,7 @@ exports.Md5Normalizer = void 0;
48
48
  const ts_utils_1 = require("@fgv/ts-utils");
49
49
  const crypto = __importStar(require("crypto"));
50
50
  /**
51
- * A {@link Hash.HashingNormalizer | hashing normalizer} which computes object
51
+ * A hashing normalizer which computes object
52
52
  * hash using the MD5 algorithm.
53
53
  * @public
54
54
  */
@@ -1 +1 @@
1
- {"version":3,"file":"md5Normalizer.js","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAqC;AACrC,+CAAiC;AACjC;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAI,CAAC,iBAAiB;IACvD;QACE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,KAAe;QACnC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;CACF;AARD,sCAQC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Hash } from '@fgv/ts-utils';\nimport * as crypto from 'crypto';\n/**\n * A {@link Hash.HashingNormalizer | hashing normalizer} which computes object\n * hash using the MD5 algorithm.\n * @public\n */\nexport class Md5Normalizer extends Hash.HashingNormalizer {\n public constructor() {\n super(Md5Normalizer.md5Hash);\n }\n\n public static md5Hash(parts: string[]): string {\n return crypto.createHash('md5').update(parts.join('|'), 'utf8').digest('hex');\n }\n}\n"]}
1
+ {"version":3,"file":"md5Normalizer.js","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAqC;AACrC,+CAAiC;AACjC;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAI,CAAC,iBAAiB;IACvD;QACE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,KAAe;QACnC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;CACF;AARD,sCAQC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Hash } from '@fgv/ts-utils';\nimport * as crypto from 'crypto';\n/**\n * A hashing normalizer which computes object\n * hash using the MD5 algorithm.\n * @public\n */\nexport class Md5Normalizer extends Hash.HashingNormalizer {\n public constructor() {\n super(Md5Normalizer.md5Hash);\n }\n\n public static md5Hash(parts: string[]): string {\n return crypto.createHash('md5').update(parts.join('|'), 'utf8').digest('hex');\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-extras",
3
- "version": "2.1.1-alpha.3",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "Assorted Typescript Utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-extras.d.ts",
@@ -46,8 +46,8 @@
46
46
  "@types/heft-jest": "1.0.6",
47
47
  "@rushstack/heft-jest-plugin": "~0.11.0",
48
48
  "eslint-plugin-tsdoc": "~0.2.17",
49
- "@fgv/ts-utils-jest": "2.1.1-alpha.3",
50
- "@fgv/ts-utils": "2.1.1-alpha.3"
49
+ "@fgv/ts-utils-jest": "3.0.0-alpha.1",
50
+ "@fgv/ts-utils": "3.0.0-alpha.1"
51
51
  },
52
52
  "dependencies": {
53
53
  "luxon": "^3.4.4",
@@ -55,7 +55,7 @@
55
55
  "papaparse": "^5.4.1"
56
56
  },
57
57
  "peerDependencies": {
58
- "@fgv/ts-utils": "2.1.1-alpha.3"
58
+ "@fgv/ts-utils": "3.0.0-alpha.1"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "heft test --clean",