@fgv/ts-utils 4.4.0 → 4.5.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 (102) hide show
  1. package/dist/ts-utils.d.ts +4247 -3635
  2. package/dist/tsdoc-metadata.json +1 -1
  3. package/lib/index.d.ts +3 -2
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.js +6 -3
  6. package/lib/index.js.map +1 -1
  7. package/lib/packlets/base/utils.d.ts.map +1 -1
  8. package/lib/packlets/base/utils.js +0 -1
  9. package/lib/packlets/base/utils.js.map +1 -1
  10. package/lib/packlets/collections/collectible.d.ts +49 -7
  11. package/lib/packlets/collections/collectible.d.ts.map +1 -1
  12. package/lib/packlets/collections/collectible.js +0 -9
  13. package/lib/packlets/collections/collectible.js.map +1 -1
  14. package/lib/packlets/collections/collector.d.ts +70 -135
  15. package/lib/packlets/collections/collector.d.ts.map +1 -1
  16. package/lib/packlets/collections/collector.js +80 -91
  17. package/lib/packlets/collections/collector.js.map +1 -1
  18. package/lib/packlets/collections/collectorValidator.d.ts +89 -0
  19. package/lib/packlets/collections/collectorValidator.d.ts.map +1 -0
  20. package/lib/packlets/collections/collectorValidator.js +98 -0
  21. package/lib/packlets/collections/collectorValidator.js.map +1 -0
  22. package/lib/packlets/collections/convertingCollector.d.ts +80 -45
  23. package/lib/packlets/collections/convertingCollector.d.ts.map +1 -1
  24. package/lib/packlets/collections/convertingCollector.js +74 -19
  25. package/lib/packlets/collections/convertingCollector.js.map +1 -1
  26. package/lib/packlets/collections/convertingCollectorValidator.d.ts +69 -0
  27. package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +1 -0
  28. package/lib/packlets/collections/{collectorConverter.js → convertingCollectorValidator.js} +10 -9
  29. package/lib/packlets/collections/convertingCollectorValidator.js.map +1 -0
  30. package/lib/packlets/collections/index.d.ts +7 -5
  31. package/lib/packlets/collections/index.d.ts.map +1 -1
  32. package/lib/packlets/collections/index.js +7 -5
  33. package/lib/packlets/collections/index.js.map +1 -1
  34. package/lib/packlets/collections/readonlyResultMap.d.ts +0 -4
  35. package/lib/packlets/collections/readonlyResultMap.d.ts.map +1 -1
  36. package/lib/packlets/collections/readonlyResultMap.js.map +1 -1
  37. package/lib/packlets/collections/resultMap.d.ts +0 -4
  38. package/lib/packlets/collections/resultMap.d.ts.map +1 -1
  39. package/lib/packlets/collections/resultMap.js +0 -6
  40. package/lib/packlets/collections/resultMap.js.map +1 -1
  41. package/lib/packlets/collections/{resultMapConverter.d.ts → resultMapValidator.d.ts} +11 -11
  42. package/lib/packlets/collections/{resultMapConverter.d.ts.map → resultMapValidator.d.ts.map} +1 -1
  43. package/lib/packlets/collections/{resultMapConverter.js → resultMapValidator.js} +6 -6
  44. package/lib/packlets/collections/{resultMapConverter.js.map → resultMapValidator.js.map} +1 -1
  45. package/lib/packlets/collections/validatingCollector.d.ts +69 -0
  46. package/lib/packlets/collections/validatingCollector.d.ts.map +1 -0
  47. package/lib/packlets/collections/validatingCollector.js +67 -0
  48. package/lib/packlets/collections/validatingCollector.js.map +1 -0
  49. package/lib/packlets/collections/validatingConvertingCollector.d.ts +59 -0
  50. package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +1 -0
  51. package/lib/packlets/collections/validatingConvertingCollector.js +68 -0
  52. package/lib/packlets/collections/validatingConvertingCollector.js.map +1 -0
  53. package/lib/packlets/collections/{convertingResultMap.d.ts → validatingResultMap.d.ts} +16 -16
  54. package/lib/packlets/collections/{convertingResultMap.d.ts.map → validatingResultMap.d.ts.map} +1 -1
  55. package/lib/packlets/collections/{convertingResultMap.js → validatingResultMap.js} +11 -11
  56. package/lib/packlets/collections/{convertingResultMap.js.map → validatingResultMap.js.map} +1 -1
  57. package/lib/packlets/file-tree/directoryItem.d.ts +47 -0
  58. package/lib/packlets/file-tree/directoryItem.d.ts.map +1 -0
  59. package/lib/packlets/file-tree/directoryItem.js +71 -0
  60. package/lib/packlets/file-tree/directoryItem.js.map +1 -0
  61. package/lib/packlets/file-tree/fileItem.d.ts +64 -0
  62. package/lib/packlets/file-tree/fileItem.d.ts.map +1 -0
  63. package/lib/packlets/file-tree/fileItem.js +93 -0
  64. package/lib/packlets/file-tree/fileItem.js.map +1 -0
  65. package/lib/packlets/file-tree/fileTree.d.ts +84 -0
  66. package/lib/packlets/file-tree/fileTree.d.ts.map +1 -0
  67. package/lib/packlets/file-tree/fileTree.js +135 -0
  68. package/lib/packlets/file-tree/fileTree.js.map +1 -0
  69. package/lib/packlets/file-tree/fileTreeAccessors.d.ts +134 -0
  70. package/lib/packlets/file-tree/fileTreeAccessors.d.ts.map +1 -0
  71. package/lib/packlets/file-tree/fileTreeAccessors.js +24 -0
  72. package/lib/packlets/file-tree/fileTreeAccessors.js.map +1 -0
  73. package/lib/packlets/file-tree/fsTree.d.ts +45 -0
  74. package/lib/packlets/file-tree/fsTree.d.ts.map +1 -0
  75. package/lib/packlets/file-tree/fsTree.js +116 -0
  76. package/lib/packlets/file-tree/fsTree.js.map +1 -0
  77. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts +67 -0
  78. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts.map +1 -0
  79. package/lib/packlets/file-tree/in-memory/inMemoryTree.js +150 -0
  80. package/lib/packlets/file-tree/in-memory/inMemoryTree.js.map +1 -0
  81. package/lib/packlets/file-tree/in-memory/index.d.ts +2 -0
  82. package/lib/packlets/file-tree/in-memory/index.d.ts.map +1 -0
  83. package/lib/packlets/file-tree/in-memory/index.js +39 -0
  84. package/lib/packlets/file-tree/in-memory/index.js.map +1 -0
  85. package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts +106 -0
  86. package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts.map +1 -0
  87. package/lib/packlets/file-tree/in-memory/treeBuilder.js +170 -0
  88. package/lib/packlets/file-tree/in-memory/treeBuilder.js.map +1 -0
  89. package/lib/packlets/file-tree/index.d.ts +8 -0
  90. package/lib/packlets/file-tree/index.d.ts.map +1 -0
  91. package/lib/packlets/file-tree/index.js +46 -0
  92. package/lib/packlets/file-tree/index.js.map +1 -0
  93. package/lib/packlets/hash/crcNormalizer.js +1 -1
  94. package/lib/packlets/hash/crcNormalizer.js.map +1 -1
  95. package/package.json +15 -15
  96. package/lib/packlets/collections/collectorConverter.d.ts +0 -86
  97. package/lib/packlets/collections/collectorConverter.d.ts.map +0 -1
  98. package/lib/packlets/collections/collectorConverter.js.map +0 -1
  99. package/lib/packlets/collections/collectors.d.ts +0 -31
  100. package/lib/packlets/collections/collectors.d.ts.map +0 -1
  101. package/lib/packlets/collections/collectors.js +0 -54
  102. package/lib/packlets/collections/collectors.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatingCollector.js","sourceRoot":"","sources":["../../../src/packlets/collections/validatingCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgD;AAKhD,2CAAwC;AACxC,6DAA0D;AA0C1D;;;;GAIG;AACH,MAAa,mBAGX,SAAQ,qBAAgB;IASxB;;;;OAIG;IACH,YAAmB,MAAoD;;QACrE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,uCAAkB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QAC7F,KAAK,MAAM,IAAI,IAAI,MAAA,MAAM,CAAC,KAAK,mCAAI,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAGrC,MAAoD;QACpD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/CD,kDA+CC","sourcesContent":["/*\n * Copyright (c) 2025 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 { captureResult, Result } from '../base';\nimport { CollectibleKey, ICollectible } from './collectible';\nimport { IReadOnlyCollectorValidator } from './collectorValidator';\nimport { IReadOnlyValidatingResultMap } from './validatingResultMap';\nimport { KeyValueConverters } from './keyValueConverters';\nimport { Collector } from './collector';\nimport { CollectorValidator } from './collectorValidator';\n\n/**\n * A read-only interface exposing non-mutating methods of a\n * {@link Collections.ValidatingCollector | ValidatingCollector}.\n * @public\n */\n\nexport interface IReadOnlyValidatingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> extends IReadOnlyValidatingResultMap<CollectibleKey<TITEM>, TITEM> {\n /**\n * {@inheritdoc Collections.ValidatingCollector.validating}\n */\n readonly validating: IReadOnlyCollectorValidator<TITEM>;\n\n /**\n * {@inheritdoc Collections.IReadOnlyValidatingCollector.getAt}\n */\n readonly getAt: (index: number) => Result<TITEM>;\n}\n\n/**\n * Parameters for constructing a {@link Collections.ValidatingCollector | ValidatingCollector}.\n * @public\n */\nexport interface IValidatingCollectorConstructorParams<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> {\n /**\n * {@inheritdoc Collections.ICollectorValidatorCreateParams.converters}\n */\n converters: KeyValueConverters<CollectibleKey<TITEM>, TITEM>;\n\n /**\n * {@inheritdoc Collections.ICollectorConstructorParams.items}\n */\n items?: unknown[];\n}\n\n/**\n * A {@link Collections.Collector | Collector} with a {@link Collections.CollectorValidator | CollectorValidator}\n * property that enables validated use of the underlying map with weakly-typed keys and values.\n * @public\n */\nexport class ValidatingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> extends Collector<TITEM> {\n /**\n * A {@link Collections.CollectorValidator | CollectorValidator} which validates keys and values\n * before inserting them into this collector.\n */\n public readonly validating: CollectorValidator<TITEM>;\n\n protected readonly _converters: KeyValueConverters<CollectibleKey<TITEM>, TITEM>;\n\n /**\n * Constructs a new {@link Collections.ValidatingCollector | ValidatingConvertingCollector}\n * from the supplied {@link Collections.IValidatingCollectorConstructorParams | parameters}.\n * @param params - Required parameters for constructing the collector.\n */\n public constructor(params: IValidatingCollectorConstructorParams<TITEM>) {\n super();\n this._converters = params.converters;\n this.validating = new CollectorValidator({ collector: this, converters: params.converters });\n for (const item of params.items ?? []) {\n this.validating.getOrAdd(item).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Collections.ValidatingCollector | ValidatingCollector} instance from\n * the supplied {@link Collections.IValidatingCollectorConstructorParams | parameters}.\n * @param params - Required parameters for constructing the collector.\n * @returns {@link Success} with the new collector if successful, {@link Failure} otherwise.\n */\n public static createValidatingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n >(params: IValidatingCollectorConstructorParams<TITEM>): Result<ValidatingCollector<TITEM>> {\n return captureResult(() => new ValidatingCollector(params));\n }\n\n /**\n * Gets a read-only version of this collector as a\n * {@link Collections.IReadOnlyValidatingResultMap | read-only map}.\n * @returns\n */\n public toReadOnly(): IReadOnlyValidatingCollector<TITEM> {\n return this;\n }\n}\n"]}
@@ -0,0 +1,59 @@
1
+ import { Result } from '../base';
2
+ import { CollectibleFactory, CollectibleKey, ICollectible } from './collectible';
3
+ import { ConvertingCollector } from './convertingCollector';
4
+ import { ConvertingCollectorValidator } from './convertingCollectorValidator';
5
+ import { KeyValueEntry } from './common';
6
+ import { KeyValueConverters } from './keyValueConverters';
7
+ import { IReadOnlyValidatingCollector } from './validatingCollector';
8
+ /**
9
+ * Parameters for constructing a {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector}.
10
+ * @public
11
+ */
12
+ export interface IValidatingConvertingCollectorConstructorParams<TITEM extends ICollectible<any, any>, TSRC = TITEM> {
13
+ /**
14
+ * {@inheritdoc Collections.IConvertingCollectorConstructorParams.factory}
15
+ */
16
+ factory: CollectibleFactory<TITEM, TSRC>;
17
+ /**
18
+ * {@inheritdoc Collections.IConvertingCollectorValidatorCreateParams.converters}
19
+ */
20
+ converters: KeyValueConverters<CollectibleKey<TITEM>, TSRC>;
21
+ /**
22
+ * {@inheritdoc Collections.IConvertingCollectorConstructorParams.entries}
23
+ */
24
+ entries?: KeyValueEntry<CollectibleKey<TITEM>, TSRC>[];
25
+ }
26
+ /**
27
+ * A {@link Collections.ConvertingCollector | ConvertingCollector} with a
28
+ * {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator}
29
+ * property that enables validated use of the underlying map with weakly-typed keys and values.
30
+ * @public
31
+ */
32
+ export declare class ValidatingConvertingCollector<TITEM extends ICollectible<any, any>, TSRC = TITEM> extends ConvertingCollector<TITEM, TSRC> {
33
+ /**
34
+ * A {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator} which validates keys and values
35
+ * before inserting them into this collector.
36
+ */
37
+ readonly validating: ConvertingCollectorValidator<TITEM, TSRC>;
38
+ protected readonly _converters: KeyValueConverters<CollectibleKey<TITEM>, TSRC>;
39
+ /**
40
+ * Constructs a new {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector}
41
+ * from the supplied {@link Collections.IValidatingConvertingCollectorConstructorParams | parameters}.
42
+ * @param params - Required parameters for constructing the collector.
43
+ */
44
+ constructor(params: IValidatingConvertingCollectorConstructorParams<TITEM, TSRC>);
45
+ /**
46
+ * Creates a new {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector} instance from
47
+ * the supplied {@link Collections.IValidatingConvertingCollectorConstructorParams | parameters}.
48
+ * @param params - Required parameters for constructing the collector.
49
+ * @returns {@link Success} with the new collector if successful, {@link Failure} otherwise.
50
+ */
51
+ static createValidatingCollector<TITEM extends ICollectible<any, any>, TSRC = TITEM>(params: IValidatingConvertingCollectorConstructorParams<TITEM, TSRC>): Result<ValidatingConvertingCollector<TITEM, TSRC>>;
52
+ /**
53
+ * Gets a read-only version of this collector as a
54
+ * {@link Collections.IReadOnlyValidatingResultMap | read-only map}.
55
+ * @returns
56
+ */
57
+ toReadOnly(): IReadOnlyValidatingCollector<TITEM>;
58
+ }
59
+ //# sourceMappingURL=validatingConvertingCollector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatingConvertingCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/validatingConvertingCollector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,+CAA+C,CAE9D,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,IAAI,GAAG,KAAK;IAEZ;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEzC;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;IAE5D;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;CACxD;AAED;;;;;GAKG;AACH,qBAAa,6BAA6B,CAExC,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,IAAI,GAAG,KAAK,CACZ,SAAQ,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC;IACxC;;;OAGG;IACH,SAAgB,UAAU,EAAE,4BAA4B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEtE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;IAEhF;;;;OAIG;gBACgB,MAAM,EAAE,+CAA+C,CAAC,KAAK,EAAE,IAAI,CAAC;IASvF;;;;;OAKG;WACW,yBAAyB,CAErC,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,IAAI,GAAG,KAAK,EAEZ,MAAM,EAAE,+CAA+C,CAAC,KAAK,EAAE,IAAI,CAAC,GACnE,MAAM,CAAC,6BAA6B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAIrD;;;;OAIG;IACI,UAAU,IAAI,4BAA4B,CAAC,KAAK,CAAC;CAGzD"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.ValidatingConvertingCollector = void 0;
25
+ const base_1 = require("../base");
26
+ const convertingCollector_1 = require("./convertingCollector");
27
+ const convertingCollectorValidator_1 = require("./convertingCollectorValidator");
28
+ /**
29
+ * A {@link Collections.ConvertingCollector | ConvertingCollector} with a
30
+ * {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator}
31
+ * property that enables validated use of the underlying map with weakly-typed keys and values.
32
+ * @public
33
+ */
34
+ class ValidatingConvertingCollector extends convertingCollector_1.ConvertingCollector {
35
+ /**
36
+ * Constructs a new {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector}
37
+ * from the supplied {@link Collections.IValidatingConvertingCollectorConstructorParams | parameters}.
38
+ * @param params - Required parameters for constructing the collector.
39
+ */
40
+ constructor(params) {
41
+ var _a;
42
+ super({ factory: params.factory });
43
+ this._converters = params.converters;
44
+ this.validating = new convertingCollectorValidator_1.ConvertingCollectorValidator({ collector: this, converters: params.converters });
45
+ for (const entry of (_a = params.entries) !== null && _a !== void 0 ? _a : []) {
46
+ this.getOrAdd(entry[0], entry[1]).orThrow();
47
+ }
48
+ }
49
+ /**
50
+ * Creates a new {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector} instance from
51
+ * the supplied {@link Collections.IValidatingConvertingCollectorConstructorParams | parameters}.
52
+ * @param params - Required parameters for constructing the collector.
53
+ * @returns {@link Success} with the new collector if successful, {@link Failure} otherwise.
54
+ */
55
+ static createValidatingCollector(params) {
56
+ return (0, base_1.captureResult)(() => new ValidatingConvertingCollector(params));
57
+ }
58
+ /**
59
+ * Gets a read-only version of this collector as a
60
+ * {@link Collections.IReadOnlyValidatingResultMap | read-only map}.
61
+ * @returns
62
+ */
63
+ toReadOnly() {
64
+ return this;
65
+ }
66
+ }
67
+ exports.ValidatingConvertingCollector = ValidatingConvertingCollector;
68
+ //# sourceMappingURL=validatingConvertingCollector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatingConvertingCollector.js","sourceRoot":"","sources":["../../../src/packlets/collections/validatingConvertingCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgD;AAEhD,+DAA4D;AAC5D,iFAA8E;AA8B9E;;;;;GAKG;AACH,MAAa,6BAIX,SAAQ,yCAAgC;IASxC;;;;OAIG;IACH,YAAmB,MAAoE;;QACrF,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,IAAI,2DAA4B,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QACvG,KAAK,MAAM,KAAK,IAAI,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAKrC,MAAoE;QAEpE,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,6BAA6B,CAAC,MAAM,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;;OAIG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAnDD,sEAmDC","sourcesContent":["/*\n * Copyright (c) 2025 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 { captureResult, Result } from '../base';\nimport { CollectibleFactory, CollectibleKey, ICollectible } from './collectible';\nimport { ConvertingCollector } from './convertingCollector';\nimport { ConvertingCollectorValidator } from './convertingCollectorValidator';\nimport { KeyValueEntry } from './common';\nimport { KeyValueConverters } from './keyValueConverters';\nimport { IReadOnlyValidatingCollector } from './validatingCollector';\n\n/**\n * Parameters for constructing a {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector}.\n * @public\n */\nexport interface IValidatingConvertingCollectorConstructorParams<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>,\n TSRC = TITEM\n> {\n /**\n * {@inheritdoc Collections.IConvertingCollectorConstructorParams.factory}\n */\n factory: CollectibleFactory<TITEM, TSRC>;\n\n /**\n * {@inheritdoc Collections.IConvertingCollectorValidatorCreateParams.converters}\n */\n converters: KeyValueConverters<CollectibleKey<TITEM>, TSRC>;\n\n /**\n * {@inheritdoc Collections.IConvertingCollectorConstructorParams.entries}\n */\n entries?: KeyValueEntry<CollectibleKey<TITEM>, TSRC>[];\n}\n\n/**\n * A {@link Collections.ConvertingCollector | ConvertingCollector} with a\n * {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator}\n * property that enables validated use of the underlying map with weakly-typed keys and values.\n * @public\n */\nexport class ValidatingConvertingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>,\n TSRC = TITEM\n> extends ConvertingCollector<TITEM, TSRC> {\n /**\n * A {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator} which validates keys and values\n * before inserting them into this collector.\n */\n public readonly validating: ConvertingCollectorValidator<TITEM, TSRC>;\n\n protected readonly _converters: KeyValueConverters<CollectibleKey<TITEM>, TSRC>;\n\n /**\n * Constructs a new {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector}\n * from the supplied {@link Collections.IValidatingConvertingCollectorConstructorParams | parameters}.\n * @param params - Required parameters for constructing the collector.\n */\n public constructor(params: IValidatingConvertingCollectorConstructorParams<TITEM, TSRC>) {\n super({ factory: params.factory });\n this._converters = params.converters;\n this.validating = new ConvertingCollectorValidator({ collector: this, converters: params.converters });\n for (const entry of params.entries ?? []) {\n this.getOrAdd(entry[0], entry[1]).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Collections.ValidatingConvertingCollector | ValidatingConvertingCollector} instance from\n * the supplied {@link Collections.IValidatingConvertingCollectorConstructorParams | parameters}.\n * @param params - Required parameters for constructing the collector.\n * @returns {@link Success} with the new collector if successful, {@link Failure} otherwise.\n */\n public static createValidatingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>,\n TSRC = TITEM\n >(\n params: IValidatingConvertingCollectorConstructorParams<TITEM, TSRC>\n ): Result<ValidatingConvertingCollector<TITEM, TSRC>> {\n return captureResult(() => new ValidatingConvertingCollector(params));\n }\n\n /**\n * Gets a read-only version of this collector as a\n * {@link Collections.IReadOnlyValidatingResultMap | read-only map}.\n * @returns\n */\n public toReadOnly(): IReadOnlyValidatingCollector<TITEM> {\n return this;\n }\n}\n"]}
@@ -3,51 +3,51 @@ import { KeyValueEntry } from './common';
3
3
  import { KeyValueConverters } from './keyValueConverters';
4
4
  import { IReadOnlyResultMap } from './readonlyResultMap';
5
5
  import { ResultMap } from './resultMap';
6
- import { IReadOnlyResultMapConverter, ResultMapConverter } from './resultMapConverter';
6
+ import { IReadOnlyResultMapValidator, ResultMapValidator } from './resultMapValidator';
7
7
  /**
8
- * A read-only interface exposing non-mutating methods of a {@link Collections.ConvertingResultMap | ConvertingResultMap}.
8
+ * A read-only interface exposing non-mutating methods of a {@link Collections.ValidatingResultMap | ValidatingResultMap}.
9
9
  * @public
10
10
  */
11
- export interface IReadOnlyConvertingResultMap<TK extends string = string, TV = unknown> extends IReadOnlyResultMap<TK, TV> {
11
+ export interface IReadOnlyValidatingResultMap<TK extends string = string, TV = unknown> extends IReadOnlyResultMap<TK, TV> {
12
12
  /**
13
- * {@inheritdoc Collections.ConvertingResultMap.converting}
13
+ * {@inheritdoc Collections.ValidatingResultMap.validating}
14
14
  */
15
- readonly converting: IReadOnlyResultMapConverter<TK, TV>;
15
+ readonly validating: IReadOnlyResultMapValidator<TK, TV>;
16
16
  }
17
17
  /**
18
18
  * Parameters for constructing a {@link Collections.ResultMap | ResultMap}.
19
19
  * @public
20
20
  */
21
- export interface IConvertingResultMapConstructorParams<TK extends string = string, TV = unknown> {
21
+ export interface IValidatingResultMapConstructorParams<TK extends string = string, TV = unknown> {
22
22
  entries?: Iterable<KeyValueEntry<string, unknown>>;
23
23
  converters: KeyValueConverters<TK, TV>;
24
24
  }
25
25
  /**
26
- * A {@link Collections.ResultMap | ResultMap} with a {@link Collections.ResultMapConverter | validator}
26
+ * A {@link Collections.ResultMap | ResultMap} with a {@link Collections.ResultMapValidator | validator}
27
27
  * property that enables validated use of the underlying map with weakly-typed keys and values.
28
28
  * @public
29
29
  */
30
- export declare class ConvertingResultMap<TK extends string = string, TV = unknown> extends ResultMap<TK, TV> implements IReadOnlyConvertingResultMap<TK, TV> {
30
+ export declare class ValidatingResultMap<TK extends string = string, TV = unknown> extends ResultMap<TK, TV> implements IReadOnlyValidatingResultMap<TK, TV> {
31
31
  /**
32
- * A {@link Collections.ResultMapConverter | ResultMapConverter} which validates keys and values
32
+ * A {@link Collections.ResultMapValidator | ResultMapValidator} which validates keys and values
33
33
  * before inserting them into this collection.
34
34
  */
35
- readonly converting: ResultMapConverter<TK, TV>;
35
+ readonly validating: ResultMapValidator<TK, TV>;
36
36
  /**
37
- * Constructs a new {@link Collections.ConvertingResultMap | ConvertingResultMap}.
37
+ * Constructs a new {@link Collections.ValidatingResultMap | ValidatingResultMap}.
38
38
  * @param params - Required parameters for constructing the map.
39
39
  */
40
- constructor(params: IConvertingResultMapConstructorParams<TK, TV>);
40
+ constructor(params: IValidatingResultMapConstructorParams<TK, TV>);
41
41
  /**
42
- * Creates a new {@link Collections.ConvertingResultMap | ConvertingResultMap} instance.
42
+ * Creates a new {@link Collections.ValidatingResultMap | ValidatingResultMap} instance.
43
43
  * @param params - Required parameters for constructing the map.
44
44
  * @returns `Success` with the new map if successful, `Failure` otherwise.
45
45
  * @public
46
46
  */
47
- static createConvertingResultMap<TK extends string = string, TV = unknown>(params: IConvertingResultMapConstructorParams<TK, TV>): Result<ConvertingResultMap<TK, TV>>;
47
+ static createValidatingResultMap<TK extends string = string, TV = unknown>(params: IValidatingResultMapConstructorParams<TK, TV>): Result<ValidatingResultMap<TK, TV>>;
48
48
  /**
49
49
  * Gets a read-only version of this map.
50
50
  */
51
- toReadOnly(): IReadOnlyConvertingResultMap<TK, TV>;
51
+ toReadOnly(): IReadOnlyValidatingResultMap<TK, TV>;
52
52
  }
53
- //# sourceMappingURL=convertingResultMap.d.ts.map
53
+ //# sourceMappingURL=validatingResultMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertingResultMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/convertingResultMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEvF;;;GAGG;AACH,MAAM,WAAW,4BAA4B,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,CACpF,SAAQ,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;CAC1D;AAED;;;GAGG;AACH,MAAM,WAAW,qCAAqC,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IAC7F,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,UAAU,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;CACxC;AAED;;;;GAIG;AACH,qBAAa,mBAAmB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,CACvE,SAAQ,SAAS,CAAC,EAAE,EAAE,EAAE,CACxB,YAAW,4BAA4B,CAAC,EAAE,EAAE,EAAE,CAAC;IAE/C;;;OAGG;IACH,SAAgB,UAAU,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAEvD;;;OAGG;gBACgB,MAAM,EAAE,qCAAqC,CAAC,EAAE,EAAE,EAAE,CAAC;IAMxE;;;;;OAKG;WACW,yBAAyB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,EAC9E,MAAM,EAAE,qCAAqC,CAAC,EAAE,EAAE,EAAE,CAAC,GACpD,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAItC;;OAEG;IACI,UAAU,IAAI,4BAA4B,CAAC,EAAE,EAAE,EAAE,CAAC;CAG1D"}
1
+ {"version":3,"file":"validatingResultMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/validatingResultMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEvF;;;GAGG;AACH,MAAM,WAAW,4BAA4B,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,CACpF,SAAQ,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;CAC1D;AAED;;;GAGG;AACH,MAAM,WAAW,qCAAqC,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IAC7F,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,UAAU,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;CACxC;AAED;;;;GAIG;AACH,qBAAa,mBAAmB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,CACvE,SAAQ,SAAS,CAAC,EAAE,EAAE,EAAE,CACxB,YAAW,4BAA4B,CAAC,EAAE,EAAE,EAAE,CAAC;IAE/C;;;OAGG;IACH,SAAgB,UAAU,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAEvD;;;OAGG;gBACgB,MAAM,EAAE,qCAAqC,CAAC,EAAE,EAAE,EAAE,CAAC;IAMxE;;;;;OAKG;WACW,yBAAyB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,EAC9E,MAAM,EAAE,qCAAqC,CAAC,EAAE,EAAE,EAAE,CAAC,GACpD,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAItC;;OAEG;IACI,UAAU,IAAI,4BAA4B,CAAC,EAAE,EAAE,EAAE,CAAC;CAG1D"}
@@ -21,34 +21,34 @@
21
21
  * SOFTWARE.
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.ConvertingResultMap = void 0;
24
+ exports.ValidatingResultMap = void 0;
25
25
  const base_1 = require("../base");
26
26
  const resultMap_1 = require("./resultMap");
27
- const resultMapConverter_1 = require("./resultMapConverter");
27
+ const resultMapValidator_1 = require("./resultMapValidator");
28
28
  /**
29
- * A {@link Collections.ResultMap | ResultMap} with a {@link Collections.ResultMapConverter | validator}
29
+ * A {@link Collections.ResultMap | ResultMap} with a {@link Collections.ResultMapValidator | validator}
30
30
  * property that enables validated use of the underlying map with weakly-typed keys and values.
31
31
  * @public
32
32
  */
33
- class ConvertingResultMap extends resultMap_1.ResultMap {
33
+ class ValidatingResultMap extends resultMap_1.ResultMap {
34
34
  /**
35
- * Constructs a new {@link Collections.ConvertingResultMap | ConvertingResultMap}.
35
+ * Constructs a new {@link Collections.ValidatingResultMap | ValidatingResultMap}.
36
36
  * @param params - Required parameters for constructing the map.
37
37
  */
38
38
  constructor(params) {
39
39
  var _a;
40
40
  const entries = params.converters.convertEntries([...((_a = params.entries) !== null && _a !== void 0 ? _a : [])]).orThrow();
41
41
  super({ entries });
42
- this.converting = new resultMapConverter_1.ResultMapConverter({ map: this, converters: params.converters });
42
+ this.validating = new resultMapValidator_1.ResultMapValidator({ map: this, converters: params.converters });
43
43
  }
44
44
  /**
45
- * Creates a new {@link Collections.ConvertingResultMap | ConvertingResultMap} instance.
45
+ * Creates a new {@link Collections.ValidatingResultMap | ValidatingResultMap} instance.
46
46
  * @param params - Required parameters for constructing the map.
47
47
  * @returns `Success` with the new map if successful, `Failure` otherwise.
48
48
  * @public
49
49
  */
50
- static createConvertingResultMap(params) {
51
- return (0, base_1.captureResult)(() => new ConvertingResultMap(params));
50
+ static createValidatingResultMap(params) {
51
+ return (0, base_1.captureResult)(() => new ValidatingResultMap(params));
52
52
  }
53
53
  /**
54
54
  * Gets a read-only version of this map.
@@ -57,5 +57,5 @@ class ConvertingResultMap extends resultMap_1.ResultMap {
57
57
  return this;
58
58
  }
59
59
  }
60
- exports.ConvertingResultMap = ConvertingResultMap;
61
- //# sourceMappingURL=convertingResultMap.js.map
60
+ exports.ValidatingResultMap = ValidatingResultMap;
61
+ //# sourceMappingURL=validatingResultMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertingResultMap.js","sourceRoot":"","sources":["../../../src/packlets/collections/convertingResultMap.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgD;AAIhD,2CAAwC;AACxC,6DAAuF;AAuBvF;;;;GAIG;AACH,MAAa,mBACX,SAAQ,qBAAiB;IASzB;;;OAGG;IACH,YAAmB,MAAqD;;QACtE,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACxF,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,IAAI,uCAAkB,CAAS,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CACrC,MAAqD;QAErD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtCD,kDAsCC","sourcesContent":["/*\n * Copyright (c) 2025 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 { captureResult, Result } from '../base';\nimport { KeyValueEntry } from './common';\nimport { KeyValueConverters } from './keyValueConverters';\nimport { IReadOnlyResultMap } from './readonlyResultMap';\nimport { ResultMap } from './resultMap';\nimport { IReadOnlyResultMapConverter, ResultMapConverter } from './resultMapConverter';\n\n/**\n * A read-only interface exposing non-mutating methods of a {@link Collections.ConvertingResultMap | ConvertingResultMap}.\n * @public\n */\nexport interface IReadOnlyConvertingResultMap<TK extends string = string, TV = unknown>\n extends IReadOnlyResultMap<TK, TV> {\n /**\n * {@inheritdoc Collections.ConvertingResultMap.converting}\n */\n readonly converting: IReadOnlyResultMapConverter<TK, TV>;\n}\n\n/**\n * Parameters for constructing a {@link Collections.ResultMap | ResultMap}.\n * @public\n */\nexport interface IConvertingResultMapConstructorParams<TK extends string = string, TV = unknown> {\n entries?: Iterable<KeyValueEntry<string, unknown>>;\n converters: KeyValueConverters<TK, TV>;\n}\n\n/**\n * A {@link Collections.ResultMap | ResultMap} with a {@link Collections.ResultMapConverter | validator}\n * property that enables validated use of the underlying map with weakly-typed keys and values.\n * @public\n */\nexport class ConvertingResultMap<TK extends string = string, TV = unknown>\n extends ResultMap<TK, TV>\n implements IReadOnlyConvertingResultMap<TK, TV>\n{\n /**\n * A {@link Collections.ResultMapConverter | ResultMapConverter} which validates keys and values\n * before inserting them into this collection.\n */\n public readonly converting: ResultMapConverter<TK, TV>;\n\n /**\n * Constructs a new {@link Collections.ConvertingResultMap | ConvertingResultMap}.\n * @param params - Required parameters for constructing the map.\n */\n public constructor(params: IConvertingResultMapConstructorParams<TK, TV>) {\n const entries = params.converters.convertEntries([...(params.entries ?? [])]).orThrow();\n super({ entries });\n this.converting = new ResultMapConverter<TK, TV>({ map: this, converters: params.converters });\n }\n\n /**\n * Creates a new {@link Collections.ConvertingResultMap | ConvertingResultMap} instance.\n * @param params - Required parameters for constructing the map.\n * @returns `Success` with the new map if successful, `Failure` otherwise.\n * @public\n */\n public static createConvertingResultMap<TK extends string = string, TV = unknown>(\n params: IConvertingResultMapConstructorParams<TK, TV>\n ): Result<ConvertingResultMap<TK, TV>> {\n return captureResult(() => new ConvertingResultMap(params));\n }\n\n /**\n * Gets a read-only version of this map.\n */\n public toReadOnly(): IReadOnlyConvertingResultMap<TK, TV> {\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"validatingResultMap.js","sourceRoot":"","sources":["../../../src/packlets/collections/validatingResultMap.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgD;AAIhD,2CAAwC;AACxC,6DAAuF;AAuBvF;;;;GAIG;AACH,MAAa,mBACX,SAAQ,qBAAiB;IASzB;;;OAGG;IACH,YAAmB,MAAqD;;QACtE,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACxF,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,IAAI,uCAAkB,CAAS,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CACrC,MAAqD;QAErD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtCD,kDAsCC","sourcesContent":["/*\n * Copyright (c) 2025 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 { captureResult, Result } from '../base';\nimport { KeyValueEntry } from './common';\nimport { KeyValueConverters } from './keyValueConverters';\nimport { IReadOnlyResultMap } from './readonlyResultMap';\nimport { ResultMap } from './resultMap';\nimport { IReadOnlyResultMapValidator, ResultMapValidator } from './resultMapValidator';\n\n/**\n * A read-only interface exposing non-mutating methods of a {@link Collections.ValidatingResultMap | ValidatingResultMap}.\n * @public\n */\nexport interface IReadOnlyValidatingResultMap<TK extends string = string, TV = unknown>\n extends IReadOnlyResultMap<TK, TV> {\n /**\n * {@inheritdoc Collections.ValidatingResultMap.validating}\n */\n readonly validating: IReadOnlyResultMapValidator<TK, TV>;\n}\n\n/**\n * Parameters for constructing a {@link Collections.ResultMap | ResultMap}.\n * @public\n */\nexport interface IValidatingResultMapConstructorParams<TK extends string = string, TV = unknown> {\n entries?: Iterable<KeyValueEntry<string, unknown>>;\n converters: KeyValueConverters<TK, TV>;\n}\n\n/**\n * A {@link Collections.ResultMap | ResultMap} with a {@link Collections.ResultMapValidator | validator}\n * property that enables validated use of the underlying map with weakly-typed keys and values.\n * @public\n */\nexport class ValidatingResultMap<TK extends string = string, TV = unknown>\n extends ResultMap<TK, TV>\n implements IReadOnlyValidatingResultMap<TK, TV>\n{\n /**\n * A {@link Collections.ResultMapValidator | ResultMapValidator} which validates keys and values\n * before inserting them into this collection.\n */\n public readonly validating: ResultMapValidator<TK, TV>;\n\n /**\n * Constructs a new {@link Collections.ValidatingResultMap | ValidatingResultMap}.\n * @param params - Required parameters for constructing the map.\n */\n public constructor(params: IValidatingResultMapConstructorParams<TK, TV>) {\n const entries = params.converters.convertEntries([...(params.entries ?? [])]).orThrow();\n super({ entries });\n this.validating = new ResultMapValidator<TK, TV>({ map: this, converters: params.converters });\n }\n\n /**\n * Creates a new {@link Collections.ValidatingResultMap | ValidatingResultMap} instance.\n * @param params - Required parameters for constructing the map.\n * @returns `Success` with the new map if successful, `Failure` otherwise.\n * @public\n */\n public static createValidatingResultMap<TK extends string = string, TV = unknown>(\n params: IValidatingResultMapConstructorParams<TK, TV>\n ): Result<ValidatingResultMap<TK, TV>> {\n return captureResult(() => new ValidatingResultMap(params));\n }\n\n /**\n * Gets a read-only version of this map.\n */\n public toReadOnly(): IReadOnlyValidatingResultMap<TK, TV> {\n return this;\n }\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import { Result } from '../base';
2
+ import { FileTreeItem, IFileTreeAccessors, IFileTreeDirectoryItem } from './fileTreeAccessors';
3
+ /**
4
+ * Class representing a directory in a file tree.
5
+ * @public
6
+ */
7
+ export declare class DirectoryItem implements IFileTreeDirectoryItem {
8
+ /**
9
+ * {@inheritdoc FileTree.IFileTreeDirectoryItem."type"}
10
+ */
11
+ readonly type: 'directory';
12
+ /**
13
+ * {@inheritdoc FileTree.IFileTreeDirectoryItem.absolutePath}
14
+ */
15
+ readonly absolutePath: string;
16
+ /**
17
+ * {@inheritdoc FileTree.IFileTreeDirectoryItem.name}
18
+ */
19
+ get name(): string;
20
+ /**
21
+ * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.
22
+ * @public
23
+ */
24
+ protected readonly _hal: IFileTreeAccessors;
25
+ /**
26
+ * Protected constructor for derived classes.
27
+ * @param path - Relative path of the directory.
28
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
29
+ * file system operations.
30
+ * @public
31
+ */
32
+ protected constructor(path: string, hal: IFileTreeAccessors);
33
+ /**
34
+ * Creates a new DirectoryItem instance.
35
+ * @param path - Relative path of the directory.
36
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
37
+ * file system operations.
38
+ * @returns A {@link Result | result} containing the new DirectoryItem instance if successful,
39
+ * or a failure if an error occurs.
40
+ */
41
+ static create(path: string, hal: IFileTreeAccessors): Result<DirectoryItem>;
42
+ /**
43
+ * {@inheritdoc FileTree.IFileTreeDirectoryItem.getChildren}
44
+ */
45
+ getChildren(): Result<ReadonlyArray<FileTreeItem>>;
46
+ }
47
+ //# sourceMappingURL=directoryItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryItem.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryItem.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE/F;;;GAGG;AACH,qBAAa,aAAc,YAAW,sBAAsB;IAC1D;;OAEG;IACH,SAAgB,IAAI,EAAE,WAAW,CAAe;IAEhD;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAE5C;;;;;;OAMG;IACH,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB;IAK3D;;;;;;;OAOG;WACW,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAAC,aAAa,CAAC;IAIlF;;OAEG;IACI,WAAW,IAAI,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;CAG1D"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.DirectoryItem = void 0;
25
+ const base_1 = require("../base");
26
+ /**
27
+ * Class representing a directory in a file tree.
28
+ * @public
29
+ */
30
+ class DirectoryItem {
31
+ /**
32
+ * {@inheritdoc FileTree.IFileTreeDirectoryItem.name}
33
+ */
34
+ get name() {
35
+ return this._hal.getBaseName(this.absolutePath);
36
+ }
37
+ /**
38
+ * Protected constructor for derived classes.
39
+ * @param path - Relative path of the directory.
40
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
41
+ * file system operations.
42
+ * @public
43
+ */
44
+ constructor(path, hal) {
45
+ /**
46
+ * {@inheritdoc FileTree.IFileTreeDirectoryItem."type"}
47
+ */
48
+ this.type = 'directory';
49
+ this._hal = hal;
50
+ this.absolutePath = hal.resolveAbsolutePath(path);
51
+ }
52
+ /**
53
+ * Creates a new DirectoryItem instance.
54
+ * @param path - Relative path of the directory.
55
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
56
+ * file system operations.
57
+ * @returns A {@link Result | result} containing the new DirectoryItem instance if successful,
58
+ * or a failure if an error occurs.
59
+ */
60
+ static create(path, hal) {
61
+ return (0, base_1.captureResult)(() => new DirectoryItem(path, hal));
62
+ }
63
+ /**
64
+ * {@inheritdoc FileTree.IFileTreeDirectoryItem.getChildren}
65
+ */
66
+ getChildren() {
67
+ return this._hal.getChildren(this.absolutePath);
68
+ }
69
+ }
70
+ exports.DirectoryItem = DirectoryItem;
71
+ //# sourceMappingURL=directoryItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryItem.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgD;AAGhD;;;GAGG;AACH,MAAa,aAAa;IAWxB;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAQD;;;;;;OAMG;IACH,YAAsB,IAAY,EAAE,GAAuB;QA9B3D;;WAEG;QACa,SAAI,GAAgB,WAAW,CAAC;QA4B9C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,GAAuB;QACxD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;CACF;AAtDD,sCAsDC","sourcesContent":["/*\n * Copyright (c) 2025 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 '../base';\nimport { FileTreeItem, IFileTreeAccessors, IFileTreeDirectoryItem } from './fileTreeAccessors';\n\n/**\n * Class representing a directory in a file tree.\n * @public\n */\nexport class DirectoryItem implements IFileTreeDirectoryItem {\n /**\n * {@inheritdoc FileTree.IFileTreeDirectoryItem.\"type\"}\n */\n public readonly type: 'directory' = 'directory';\n\n /**\n * {@inheritdoc FileTree.IFileTreeDirectoryItem.absolutePath}\n */\n public readonly absolutePath: string;\n\n /**\n * {@inheritdoc FileTree.IFileTreeDirectoryItem.name}\n */\n public get name(): string {\n return this._hal.getBaseName(this.absolutePath);\n }\n\n /**\n * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.\n * @public\n */\n protected readonly _hal: IFileTreeAccessors;\n\n /**\n * Protected constructor for derived classes.\n * @param path - Relative path of the directory.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @public\n */\n protected constructor(path: string, hal: IFileTreeAccessors) {\n this._hal = hal;\n this.absolutePath = hal.resolveAbsolutePath(path);\n }\n\n /**\n * Creates a new DirectoryItem instance.\n * @param path - Relative path of the directory.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @returns A {@link Result | result} containing the new DirectoryItem instance if successful,\n * or a failure if an error occurs.\n */\n public static create(path: string, hal: IFileTreeAccessors): Result<DirectoryItem> {\n return captureResult(() => new DirectoryItem(path, hal));\n }\n\n /**\n * {@inheritdoc FileTree.IFileTreeDirectoryItem.getChildren}\n */\n public getChildren(): Result<ReadonlyArray<FileTreeItem>> {\n return this._hal.getChildren(this.absolutePath);\n }\n}\n"]}
@@ -0,0 +1,64 @@
1
+ import { Result } from '../base';
2
+ import { Converter } from '../conversion';
3
+ import { Validator } from '../validation';
4
+ import { IFileTreeAccessors, IFileTreeFileItem } from './fileTreeAccessors';
5
+ /**
6
+ * Class representing a file in a file tree.
7
+ * @public
8
+ */
9
+ export declare class FileItem implements IFileTreeFileItem {
10
+ /**
11
+ * {@inheritdoc FileTree.IFileTreeFileItem."type"}
12
+ */
13
+ readonly type: 'file';
14
+ /**
15
+ * {@inheritdoc FileTree.IFileTreeFileItem.absolutePath}
16
+ */
17
+ readonly absolutePath: string;
18
+ /**
19
+ * {@inheritdoc FileTree.IFileTreeFileItem.name}
20
+ */
21
+ get name(): string;
22
+ /**
23
+ * {@inheritdoc FileTree.IFileTreeFileItem.baseName}
24
+ */
25
+ get baseName(): string;
26
+ /**
27
+ * {@inheritdoc FileTree.IFileTreeFileItem.extension}
28
+ */
29
+ get extension(): string;
30
+ /**
31
+ * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.
32
+ * @public
33
+ */
34
+ protected readonly _hal: IFileTreeAccessors;
35
+ /**
36
+ * Protected constructor for derived classes.
37
+ * @param path - Relative path of the file.
38
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
39
+ * file system operations.
40
+ * @public
41
+ */
42
+ protected constructor(path: string, hal: IFileTreeAccessors);
43
+ /**
44
+ * Creates a new {@link FileTree.FileItem | FileItem} instance.
45
+ * @param path - Relative path of the file.
46
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
47
+ * file system operations.
48
+ * @public
49
+ */
50
+ static create(path: string, hal: IFileTreeAccessors): Result<FileItem>;
51
+ /**
52
+ * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:1)}
53
+ */
54
+ getContents(): Result<unknown>;
55
+ /**
56
+ * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:2)}
57
+ */
58
+ getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;
59
+ /**
60
+ * {@inheritdoc FileTree.IFileTreeFileItem.getRawContents}
61
+ */
62
+ getRawContents(): Result<string>;
63
+ }
64
+ //# sourceMappingURL=fileItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileItem.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileItem.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAW,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;GAGG;AACH,qBAAa,QAAS,YAAW,iBAAiB;IAChD;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAU;IAEtC;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAE5C;;;;;;OAMG;IACH,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB;IAK3D;;;;;;OAMG;WACW,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAAC,QAAQ,CAAC;IAI7E;;OAEG;IACI,WAAW,IAAI,MAAM,CAAC,OAAO,CAAC;IACrC;;OAEG;IACI,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAaxE;;OAEG;IACI,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC;CAGxC"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.FileItem = void 0;
25
+ const base_1 = require("../base");
26
+ /**
27
+ * Class representing a file in a file tree.
28
+ * @public
29
+ */
30
+ class FileItem {
31
+ /**
32
+ * {@inheritdoc FileTree.IFileTreeFileItem.name}
33
+ */
34
+ get name() {
35
+ return this._hal.getBaseName(this.absolutePath);
36
+ }
37
+ /**
38
+ * {@inheritdoc FileTree.IFileTreeFileItem.baseName}
39
+ */
40
+ get baseName() {
41
+ return this._hal.getBaseName(this.absolutePath, this.extension);
42
+ }
43
+ /**
44
+ * {@inheritdoc FileTree.IFileTreeFileItem.extension}
45
+ */
46
+ get extension() {
47
+ return this._hal.getExtension(this.absolutePath);
48
+ }
49
+ /**
50
+ * Protected constructor for derived classes.
51
+ * @param path - Relative path of the file.
52
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
53
+ * file system operations.
54
+ * @public
55
+ */
56
+ constructor(path, hal) {
57
+ /**
58
+ * {@inheritdoc FileTree.IFileTreeFileItem."type"}
59
+ */
60
+ this.type = 'file';
61
+ this._hal = hal;
62
+ this.absolutePath = hal.resolveAbsolutePath(path);
63
+ }
64
+ /**
65
+ * Creates a new {@link FileTree.FileItem | FileItem} instance.
66
+ * @param path - Relative path of the file.
67
+ * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
68
+ * file system operations.
69
+ * @public
70
+ */
71
+ static create(path, hal) {
72
+ return (0, base_1.captureResult)(() => new FileItem(path, hal));
73
+ }
74
+ getContents(converter) {
75
+ return this._hal
76
+ .getFileContents(this.absolutePath)
77
+ .onSuccess((body) => (0, base_1.captureResult)(() => JSON.parse(body)).onFailure(() => (0, base_1.succeed)(body)))
78
+ .onSuccess((parsed) => {
79
+ if (converter !== undefined) {
80
+ return converter.convert(parsed);
81
+ }
82
+ return (0, base_1.succeed)(parsed);
83
+ });
84
+ }
85
+ /**
86
+ * {@inheritdoc FileTree.IFileTreeFileItem.getRawContents}
87
+ */
88
+ getRawContents() {
89
+ return this._hal.getFileContents(this.absolutePath);
90
+ }
91
+ }
92
+ exports.FileItem = FileItem;
93
+ //# sourceMappingURL=fileItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileItem.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAyD;AAKzD;;;GAGG;AACH,MAAa,QAAQ;IAWnB;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;IAQD;;;;;;OAMG;IACH,YAAsB,IAAY,EAAE,GAAuB;QA5C3D;;WAEG;QACa,SAAI,GAAW,MAAM,CAAC;QA0CpC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,GAAuB;QACxD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAUM,WAAW,CAAI,SAAuC;QAC3D,OAAO,IAAI,CAAC,IAAI;aACb,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC;aAClC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,CAAC;aACzF,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACpB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YACD,OAAO,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;CACF;AAvFD,4BAuFC","sourcesContent":["/*\n * Copyright (c) 2025 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 { captureResult, Result, succeed } from '../base';\nimport { Converter } from '../conversion';\nimport { Validator } from '../validation';\nimport { IFileTreeAccessors, IFileTreeFileItem } from './fileTreeAccessors';\n\n/**\n * Class representing a file in a file tree.\n * @public\n */\nexport class FileItem implements IFileTreeFileItem {\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.\"type\"}\n */\n public readonly type: 'file' = 'file';\n\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.absolutePath}\n */\n public readonly absolutePath: string;\n\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.name}\n */\n public get name(): string {\n return this._hal.getBaseName(this.absolutePath);\n }\n\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.baseName}\n */\n public get baseName(): string {\n return this._hal.getBaseName(this.absolutePath, this.extension);\n }\n\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.extension}\n */\n public get extension(): string {\n return this._hal.getExtension(this.absolutePath);\n }\n\n /**\n * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.\n * @public\n */\n protected readonly _hal: IFileTreeAccessors;\n\n /**\n * Protected constructor for derived classes.\n * @param path - Relative path of the file.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @public\n */\n protected constructor(path: string, hal: IFileTreeAccessors) {\n this._hal = hal;\n this.absolutePath = hal.resolveAbsolutePath(path);\n }\n\n /**\n * Creates a new {@link FileTree.FileItem | FileItem} instance.\n * @param path - Relative path of the file.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @public\n */\n public static create(path: string, hal: IFileTreeAccessors): Result<FileItem> {\n return captureResult(() => new FileItem(path, hal));\n }\n\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:1)}\n */\n public getContents(): Result<unknown>;\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:2)}\n */\n public getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n public getContents<T>(converter?: Validator<T> | Converter<T>): Result<T | unknown> {\n return this._hal\n .getFileContents(this.absolutePath)\n .onSuccess((body) => captureResult(() => JSON.parse(body)).onFailure(() => succeed(body)))\n .onSuccess((parsed) => {\n if (converter !== undefined) {\n return converter.convert(parsed);\n }\n return succeed(parsed);\n });\n }\n\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.getRawContents}\n */\n public getRawContents(): Result<string> {\n return this._hal.getFileContents(this.absolutePath);\n }\n}\n"]}