ts-fortress 9.2.1 → 11.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 (121) hide show
  1. package/README.md +4 -4
  2. package/dist/array/bounded-length-array.d.mts +29 -0
  3. package/dist/array/bounded-length-array.d.mts.map +1 -0
  4. package/dist/array/bounded-length-array.mjs +54 -0
  5. package/dist/array/bounded-length-array.mjs.map +1 -0
  6. package/dist/array/bounded-length-tuple.d.mts +20 -0
  7. package/dist/array/bounded-length-tuple.d.mts.map +1 -0
  8. package/dist/array/{array-bounded-length.mjs → bounded-length-tuple.mjs} +4 -4
  9. package/dist/array/bounded-length-tuple.mjs.map +1 -0
  10. package/dist/array/build-type.d.mts +28 -0
  11. package/dist/array/build-type.d.mts.map +1 -0
  12. package/dist/array/build-type.mjs +44 -0
  13. package/dist/array/build-type.mjs.map +1 -0
  14. package/dist/array/fixed-length-array.d.mts +23 -0
  15. package/dist/array/fixed-length-array.d.mts.map +1 -0
  16. package/dist/array/fixed-length-array.mjs +46 -0
  17. package/dist/array/fixed-length-array.mjs.map +1 -0
  18. package/dist/array/fixed-length-tuple.d.mts +8 -0
  19. package/dist/array/fixed-length-tuple.d.mts.map +1 -0
  20. package/dist/array/{array-of-length.mjs → fixed-length-tuple.mjs} +5 -5
  21. package/dist/array/fixed-length-tuple.mjs.map +1 -0
  22. package/dist/array/index.d.mts +8 -4
  23. package/dist/array/index.d.mts.map +1 -1
  24. package/dist/array/index.mjs +8 -4
  25. package/dist/array/index.mjs.map +1 -1
  26. package/dist/array/max-length-array.d.mts +21 -0
  27. package/dist/array/max-length-array.d.mts.map +1 -0
  28. package/dist/array/max-length-array.mjs +50 -0
  29. package/dist/array/max-length-array.mjs.map +1 -0
  30. package/dist/array/max-length-tuple.d.mts +12 -0
  31. package/dist/array/max-length-tuple.d.mts.map +1 -0
  32. package/dist/array/{array-at-most-length.mjs → max-length-tuple.mjs} +4 -4
  33. package/dist/array/max-length-tuple.mjs.map +1 -0
  34. package/dist/array/min-length-array.d.mts +21 -0
  35. package/dist/array/min-length-array.d.mts.map +1 -0
  36. package/dist/array/min-length-array.mjs +52 -0
  37. package/dist/array/min-length-array.mjs.map +1 -0
  38. package/dist/array/min-length-tuple.d.mts +12 -0
  39. package/dist/array/min-length-tuple.d.mts.map +1 -0
  40. package/dist/array/{array-at-least-length.mjs → min-length-tuple.mjs} +4 -4
  41. package/dist/array/min-length-tuple.mjs.map +1 -0
  42. package/dist/array/non-empty-array.d.mts +2 -2
  43. package/dist/array/non-empty-array.d.mts.map +1 -1
  44. package/dist/array/non-empty-array.mjs +7 -15
  45. package/dist/array/non-empty-array.mjs.map +1 -1
  46. package/dist/compose/intersection.d.mts +6 -6
  47. package/dist/compose/intersection.mjs +1 -1
  48. package/dist/compose/intersection.mjs.map +1 -1
  49. package/dist/compose/union.d.mts +5 -5
  50. package/dist/compose/union.mjs +1 -1
  51. package/dist/compose/union.mjs.map +1 -1
  52. package/dist/entry-point.mjs +8 -4
  53. package/dist/entry-point.mjs.map +1 -1
  54. package/dist/enum/enum.d.mts +3 -3
  55. package/dist/enum/enum.mjs.map +1 -1
  56. package/dist/index.mjs +8 -4
  57. package/dist/index.mjs.map +1 -1
  58. package/dist/primitives/bigint.mjs +1 -1
  59. package/dist/primitives/bigint.mjs.map +1 -1
  60. package/dist/primitives/number.mjs +1 -1
  61. package/dist/primitives/number.mjs.map +1 -1
  62. package/dist/primitives/string.d.mts +18 -16
  63. package/dist/primitives/string.d.mts.map +1 -1
  64. package/dist/primitives/string.mjs +1 -1
  65. package/dist/primitives/string.mjs.map +1 -1
  66. package/dist/record/at.mjs +1 -1
  67. package/dist/record/at.mjs.map +1 -1
  68. package/dist/record/merge-records.d.mts +2 -2
  69. package/dist/record/merge-records.mjs +1 -1
  70. package/dist/record/merge-records.mjs.map +1 -1
  71. package/dist/record/partial.d.mts +4 -4
  72. package/dist/record/partial.mjs.map +1 -1
  73. package/dist/record/required.d.mts +4 -4
  74. package/dist/record/required.mjs.map +1 -1
  75. package/dist/record/valueof.mjs +1 -1
  76. package/dist/record/valueof.mjs.map +1 -1
  77. package/package.json +4 -4
  78. package/src/array/bounded-length-array.mts +156 -0
  79. package/src/array/bounded-length-array.test.mts +66 -0
  80. package/src/array/{array-bounded-length.mts → bounded-length-tuple.mts} +22 -22
  81. package/src/array/{array-bounded-length.test.mts → bounded-length-tuple.test.mts} +20 -20
  82. package/src/array/build-type.mts +82 -0
  83. package/src/array/fixed-length-array.mts +108 -0
  84. package/src/array/fixed-length-array.test.mts +70 -0
  85. package/src/array/{array-of-length.mts → fixed-length-tuple.mts} +11 -8
  86. package/src/array/{array-of-length.test.mts → fixed-length-tuple.test.mts} +8 -8
  87. package/src/array/index.mts +8 -4
  88. package/src/array/max-length-array.mts +109 -0
  89. package/src/array/max-length-array.test.mts +52 -0
  90. package/src/array/{array-at-most-length.mts → max-length-tuple.mts} +12 -9
  91. package/src/array/{array-at-most-length.test.mts → max-length-tuple.test.mts} +11 -11
  92. package/src/array/min-length-array.mts +114 -0
  93. package/src/array/min-length-array.test.mts +54 -0
  94. package/src/array/{array-at-least-length.mts → min-length-tuple.mts} +12 -9
  95. package/src/array/{array-at-least-length.test.mts → min-length-tuple.test.mts} +12 -15
  96. package/src/array/non-empty-array.mts +17 -25
  97. package/src/array/non-empty-array.test.mts +13 -7
  98. package/src/compose/intersection.mts +7 -7
  99. package/src/compose/union.mts +6 -6
  100. package/src/enum/enum.mts +4 -4
  101. package/src/primitives/bigint.mts +1 -1
  102. package/src/primitives/number.mts +1 -1
  103. package/src/primitives/string.mts +24 -29
  104. package/src/primitives/string.test.mts +27 -20
  105. package/src/record/at.mts +1 -1
  106. package/src/record/merge-records.mts +4 -4
  107. package/src/record/partial.mts +6 -6
  108. package/src/record/required.mts +4 -4
  109. package/src/record/valueof.mts +1 -1
  110. package/dist/array/array-at-least-length.d.mts +0 -12
  111. package/dist/array/array-at-least-length.d.mts.map +0 -1
  112. package/dist/array/array-at-least-length.mjs.map +0 -1
  113. package/dist/array/array-at-most-length.d.mts +0 -12
  114. package/dist/array/array-at-most-length.d.mts.map +0 -1
  115. package/dist/array/array-at-most-length.mjs.map +0 -1
  116. package/dist/array/array-bounded-length.d.mts +0 -20
  117. package/dist/array/array-bounded-length.d.mts.map +0 -1
  118. package/dist/array/array-bounded-length.mjs.map +0 -1
  119. package/dist/array/array-of-length.d.mts +0 -8
  120. package/dist/array/array-of-length.d.mts.map +0 -1
  121. package/dist/array/array-of-length.mjs.map +0 -1
package/README.md CHANGED
@@ -1042,10 +1042,10 @@ type ValidationError = Readonly<{
1042
1042
  - `t.array(elementType)` - Array validation
1043
1043
  - `t.nonEmptyArray(elementType)` - Non-empty array validation
1044
1044
  - `t.tuple([t1, t2, ..., tN])` - Fixed-length tuple validation
1045
- - `t.arrayOfLength(size, elementType)` - Fixed-length array validation
1046
- - `t.arrayAtLeastLength(size, elementType)` - Array validation with a minimum length
1047
- - `t.arrayAtMostLength(size, elementType)` - Array validation with a maximum length
1048
- - `t.arrayBoundedLength(min, max, elementType)` - Array validation with a length between `min` and `max` (inclusive)
1045
+ - `t.fixedLengthTuple(size, elementType)` - Fixed-length array validation
1046
+ - `t.minLengthTuple(size, elementType)` - Array validation with a minimum length
1047
+ - `t.maxLengthTuple(size, elementType)` - Array validation with a maximum length
1048
+ - `t.boundedLengthTuple(min, max, elementType)` - Array validation with a length between `min` and `max` (inclusive)
1049
1049
 
1050
1050
  ### Objects
1051
1051
 
@@ -0,0 +1,29 @@
1
+ import { type BoundedLengthArray, type MaxLengthArray, type MinLengthArray, type SupportedLength } from 'ts-type-forge';
2
+ import { type Type } from '../type.mjs';
3
+ export type { BoundedLengthArray } from 'ts-type-forge';
4
+ /**
5
+ * Creates a `Type` for a readonly array whose length is within the inclusive
6
+ * range `[min, max]`, typed as the branded {@link BoundedLengthArray} instead
7
+ * of the union of tuple types produced by `boundedLengthTuple`.
8
+ *
9
+ * Because the length constraint lives only in the brand, no union of tuples
10
+ * of the element type is ever constructed, which keeps type-checking cheap
11
+ * even when `A` is a large type.
12
+ */
13
+ export declare function boundedLengthArray<A, Min extends SupportedLength, Max extends SupportedLength>(min: Min, max: Max, elementType: Type<A>, options?: Partial<Readonly<{
14
+ typeName: string;
15
+ defaultValue: BoundedLengthArray<Min, Max, A>;
16
+ }>>): Type<BoundedLengthArray<Min, Max, A>>;
17
+ export declare function boundedLengthArray<A, Min extends SupportedLength>(min: Min, max: number, elementType: Type<A>, options?: Partial<Readonly<{
18
+ typeName: string;
19
+ defaultValue: MinLengthArray<Min, A>;
20
+ }>>): Type<MinLengthArray<Min, A>>;
21
+ export declare function boundedLengthArray<A, Max extends SupportedLength>(min: number, max: Max, elementType: Type<A>, options?: Partial<Readonly<{
22
+ typeName: string;
23
+ defaultValue: MaxLengthArray<Max, A>;
24
+ }>>): Type<MaxLengthArray<Max, A>>;
25
+ export declare function boundedLengthArray<A>(min: number, max: number, elementType: Type<A>, options?: Partial<Readonly<{
26
+ typeName: string;
27
+ defaultValue: readonly A[];
28
+ }>>): Type<readonly A[]>;
29
+ //# sourceMappingURL=bounded-length-array.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-length-array.d.mts","sourceRoot":"","sources":["../../src/array/bounded-length-array.mts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAOxC,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EACD,GAAG,SAAS,eAAe,EAC3B,GAAG,SAAS,eAAe,EAE3B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,Q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SAAS,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { memoizeFunction, Arr, asUint32, Result } from 'ts-data-forge';
2
+ import { createPrimitiveValidationError } from '../utils/validation-error.mjs';
3
+ import { buildType, validateElements } from './build-type.mjs';
4
+
5
+ function boundedLengthArray(min, max, elementType, options) {
6
+ const typeName = options?.typeName ?? `BoundedLengthArray<${min}, ${max}, ${elementType.typeName}>`;
7
+ const getDefaultValue = memoizeFunction(
8
+ () => options?.defaultValue ?? // An array of the minimum length is the shortest value within the range.
9
+ Arr.create(asUint32(min), elementType.defaultValue)
10
+ );
11
+ const validate = (a) => {
12
+ if (!Arr.isArray(a)) {
13
+ return Result.err([
14
+ createPrimitiveValidationError({
15
+ actualValue: a,
16
+ expectedType: "array",
17
+ typeName,
18
+ details: void 0
19
+ })
20
+ ]);
21
+ }
22
+ if (a.length < min || max < a.length) {
23
+ return Result.err([
24
+ {
25
+ path: [],
26
+ actualValue: a,
27
+ expectedType: typeName,
28
+ typeName,
29
+ details: {
30
+ kind: "array-range-length",
31
+ minLength: min,
32
+ maxLength: max,
33
+ actualLength: a.length
34
+ }
35
+ }
36
+ ]);
37
+ }
38
+ return validateElements(a, elementType);
39
+ };
40
+ const fill = (a) => {
41
+ if (!Arr.isArray(a)) {
42
+ return getDefaultValue();
43
+ }
44
+ const capped = Arr.take(a, asUint32(max));
45
+ return capped.length >= min ? Arr.map(capped, (el) => elementType.fill(el)) : Arr.map(
46
+ Arr.seq(asUint32(min)),
47
+ (i) => elementType.fill(capped[i])
48
+ );
49
+ };
50
+ return buildType({ typeName, getDefaultValue, validate, fill, elementType });
51
+ }
52
+
53
+ export { boundedLengthArray };
54
+ //# sourceMappingURL=bounded-length-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-length-array.mjs","sources":["../../src/array/bounded-length-array.mts"],"sourcesContent":["import { Arr, asUint32, memoizeFunction, Result } from 'ts-data-forge';\nimport {\n type BoundedLengthArray,\n type MaxLengthArray,\n type MinLengthArray,\n type SupportedLength,\n} from 'ts-type-forge';\nimport { type Type } from '../type.mjs';\nimport {\n createPrimitiveValidationError,\n type ValidationError,\n} from '../utils/index.mjs';\nimport { buildType, validateElements } from './build-type.mjs';\n\nexport type { BoundedLengthArray } from 'ts-type-forge';\n\n/**\n * Creates a `Type` for a readonly array whose length is within the inclusive\n * range `[min, max]`, typed as the branded {@link BoundedLengthArray} instead\n * of the union of tuple types produced by `boundedLengthTuple`.\n *\n * Because the length constraint lives only in the brand, no union of tuples\n * of the element type is ever constructed, which keeps type-checking cheap\n * even when `A` is a large type.\n */\nexport function boundedLengthArray<\n A,\n Min extends SupportedLength,\n Max extends SupportedLength,\n>(\n min: Min,\n max: Max,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: BoundedLengthArray<Min, Max, A>;\n }>\n >,\n): Type<BoundedLengthArray<Min, Max, A>>;\n\n// Only the lower bound is in `SupportedLength`, so the upper bound is dropped from\n// the result type and only the \"at least `min`\" guarantee is kept.\nexport function boundedLengthArray<A, Min extends SupportedLength>(\n min: Min,\n max: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: MinLengthArray<Min, A>;\n }>\n >,\n): Type<MinLengthArray<Min, A>>;\n\n// Only the upper bound is in `SupportedLength`, so the lower bound is dropped from\n// the result type and only the \"at most `max`\" guarantee is kept.\nexport function boundedLengthArray<A, Max extends SupportedLength>(\n min: number,\n max: Max,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: MaxLengthArray<Max, A>;\n }>\n >,\n): Type<MaxLengthArray<Max, A>>;\n\n// Neither bound is in `SupportedLength`, so the result length is left unconstrained.\nexport function boundedLengthArray<A>(\n min: number,\n max: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]>;\n\nexport function boundedLengthArray<A>(\n min: number,\n max: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]> {\n type T = readonly A[];\n\n const typeName =\n options?.typeName ??\n `BoundedLengthArray<${min}, ${max}, ${elementType.typeName}>`;\n\n const getDefaultValue = memoizeFunction(\n (): T =>\n options?.defaultValue ??\n // An array of the minimum length is the shortest value within the range.\n Arr.create(asUint32(min), elementType.defaultValue),\n );\n\n const validate: Type<T>['validate'] = (a) => {\n if (!Arr.isArray(a)) {\n return Result.err([\n createPrimitiveValidationError({\n actualValue: a,\n expectedType: 'array',\n typeName,\n details: undefined,\n }),\n ]);\n }\n\n if (a.length < min || max < a.length) {\n return Result.err([\n {\n path: [],\n actualValue: a,\n expectedType: typeName,\n typeName,\n details: {\n kind: 'array-range-length',\n minLength: min,\n maxLength: max,\n actualLength: a.length,\n },\n } satisfies ValidationError,\n ]);\n }\n\n return validateElements(a, elementType);\n };\n\n const fill: Type<T>['fill'] = (a) => {\n if (!Arr.isArray(a)) {\n return getDefaultValue();\n }\n\n // Trim down to at most `max`, then pad up to at least `min`.\n const capped = Arr.take(a, asUint32(max));\n\n return capped.length >= min\n ? Arr.map(capped, (el) => elementType.fill(el) satisfies A)\n : Arr.map(\n Arr.seq(asUint32(min)),\n (i) => elementType.fill(capped[i]) satisfies A,\n );\n };\n\n return buildType({ typeName, getDefaultValue, validate, fill, elementType });\n}\n"],"names":[],"mappings":";;;;AAkFO,SAAS,kBAAA,CACd,GAAA,EACA,GAAA,EACA,WAAA,EACA,OAAA,EAMoB;AAGpB,EAAA,MAAM,QAAA,GACJ,SAAS,QAAA,IACT,CAAA,mBAAA,EAAsB,GAAG,CAAA,EAAA,EAAK,GAAG,CAAA,EAAA,EAAK,WAAA,CAAY,QAAQ,CAAA,CAAA,CAAA;AAE5D,EAAA,MAAM,eAAA,GAAkB,eAAA;AAAA,IACtB,MACE,OAAA,EAAS,YAAA;AAAA,IAET,IAAI,MAAA,CAAO,QAAA,CAAS,GA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IACxD,GAAA,CAAI,GAAA;AAAA,MACF,GAAA,CAAI,GAAA,CAAI,QAAA,CAAS,GAAG,CAAC,CAAA;AAAA,MACrB,CAAC,CAAA,KAAM,WAAA,CAAY,IAAA,CAAK,MAAA,CAAO,CAAC,CAAC;AAAA,KACnC;AAAA,EACN,CAAA;AAEA,EAAA,OAAO,UAAU,EAAE,QAAA,EAAU,iBAAiB,QAAA,EAAU,IAAA,EAAM,aAAa,CAAA;AAC7E;;;;"}
@@ -0,0 +1,20 @@
1
+ import { type BoundedLengthTuple, type MaxLengthTuple, type MinLengthTuple, type StructuralPrefixLength } from 'ts-type-forge';
2
+ import { type Type } from '../type.mjs';
3
+ export type { BoundedLengthTuple } from 'ts-type-forge';
4
+ export declare function boundedLengthTuple<A, Min extends StructuralPrefixLength, Max extends StructuralPrefixLength>(min: Min, max: Max, elementType: Type<A>, options?: Partial<Readonly<{
5
+ typeName: string;
6
+ defaultValue: BoundedLengthTuple<Min, Max, A>;
7
+ }>>): Type<BoundedLengthTuple<Min, Max, A>>;
8
+ export declare function boundedLengthTuple<A, Min extends StructuralPrefixLength>(min: Min, max: number, elementType: Type<A>, options?: Partial<Readonly<{
9
+ typeName: string;
10
+ defaultValue: MinLengthTuple<Min, A>;
11
+ }>>): Type<MinLengthTuple<Min, A>>;
12
+ export declare function boundedLengthTuple<A, Max extends StructuralPrefixLength>(min: number, max: Max, elementType: Type<A>, options?: Partial<Readonly<{
13
+ typeName: string;
14
+ defaultValue: MaxLengthTuple<Max, A>;
15
+ }>>): Type<MaxLengthTuple<Max, A>>;
16
+ export declare function boundedLengthTuple<A>(min: number, max: number, elementType: Type<A>, options?: Partial<Readonly<{
17
+ typeName: string;
18
+ defaultValue: readonly A[];
19
+ }>>): Type<readonly A[]>;
20
+ //# sourceMappingURL=bounded-length-tuple.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-length-tuple.d.mts","sourceRoot":"","sources":["../../src/array/bounded-length-tuple.mts"],"names":[],"mappings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MAAM,CAAC;IACjB,YAAY,EAAE,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;CACtC,CAAC,CACH,GACA,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAGhC,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC;CAC5B,CAAC,CACH,GACA,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC"}
@@ -4,8 +4,8 @@ import { createCastFn } from '../utils/create-cast-fn.mjs';
4
4
  import { createIsFn } from '../utils/create-is-fn.mjs';
5
5
  import { createPrimitiveValidationError, prependIndexToValidationErrors } from '../utils/validation-error.mjs';
6
6
 
7
- function arrayBoundedLength(min, max, elementType, options) {
8
- const typeName = options?.typeName ?? `ArrayBoundedLen<${min}, ${max}, ${elementType.typeName}>`;
7
+ function boundedLengthTuple(min, max, elementType, options) {
8
+ const typeName = options?.typeName ?? `BoundedLengthTuple<${min}, ${max}, ${elementType.typeName}>`;
9
9
  const getDefaultValue = memoizeFunction(
10
10
  () => options?.defaultValue ?? // An array of the minimum length is the shortest value within the range.
11
11
  Arr.create(asUint32(min), elementType.defaultValue)
@@ -75,5 +75,5 @@ function arrayBoundedLength(min, max, elementType, options) {
75
75
  };
76
76
  }
77
77
 
78
- export { arrayBoundedLength };
79
- //# sourceMappingURL=array-bounded-length.mjs.map
78
+ export { boundedLengthTuple };
79
+ //# sourceMappingURL=bounded-length-tuple.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-length-tuple.mjs","sources":["../../src/array/bounded-length-tuple.mts"],"sourcesContent":["import { Arr, asUint32, memoizeFunction, Result } from 'ts-data-forge';\nimport {\n type BoundedLengthTuple,\n type MaxLengthTuple,\n type MinLengthTuple,\n type StructuralPrefixLength,\n} from 'ts-type-forge';\nimport { type Type } from '../type.mjs';\nimport {\n createAssertFn,\n createCastFn,\n createIsFn,\n createPrimitiveValidationError,\n prependIndexToValidationErrors,\n type ValidationError,\n} from '../utils/index.mjs';\n\nexport type { BoundedLengthTuple } from 'ts-type-forge';\n\nexport function boundedLengthTuple<\n A,\n Min extends StructuralPrefixLength,\n Max extends StructuralPrefixLength,\n>(\n min: Min,\n max: Max,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: BoundedLengthTuple<Min, Max, A>;\n }>\n >,\n): Type<BoundedLengthTuple<Min, Max, A>>;\n\n// Only the lower bound is in `StructuralPrefixLength` (`0..10`), so the upper bound is dropped from the\n// result type and only the \"at least `min`\" guarantee is kept.\nexport function boundedLengthTuple<A, Min extends StructuralPrefixLength>(\n min: Min,\n max: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: MinLengthTuple<Min, A>;\n }>\n >,\n): Type<MinLengthTuple<Min, A>>;\n\n// Only the upper bound is in `StructuralPrefixLength` (`0..10`), so the lower bound is dropped from the\n// result type and only the \"at most `max`\" guarantee is kept.\nexport function boundedLengthTuple<A, Max extends StructuralPrefixLength>(\n min: number,\n max: Max,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: MaxLengthTuple<Max, A>;\n }>\n >,\n): Type<MaxLengthTuple<Max, A>>;\n\n// Neither bound is in `StructuralPrefixLength` (`0..10`), so the result length is left unconstrained.\nexport function boundedLengthTuple<A>(\n min: number,\n max: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]>;\n\nexport function boundedLengthTuple<A>(\n min: number,\n max: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]> {\n type T = readonly A[];\n\n const typeName =\n options?.typeName ??\n `BoundedLengthTuple<${min}, ${max}, ${elementType.typeName}>`;\n\n const getDefaultValue = memoizeFunction(\n (): T =>\n options?.defaultValue ??\n // An array of the minimum length is the shortest value within the range.\n Arr.create(asUint32(min), elementType.defaultValue),\n );\n\n const validate: Type<T>['validate'] = (a) => {\n if (!Arr.isArray(a)) {\n return Result.err([\n createPrimitiveValidationError({\n actualValue: a,\n expectedType: 'array',\n typeName,\n details: undefined,\n }),\n ]);\n }\n\n if (a.length < min || max < a.length) {\n return Result.err([\n {\n path: [],\n actualValue: a,\n expectedType: typeName,\n typeName,\n details: {\n kind: 'array-range-length',\n minLength: min,\n maxLength: max,\n actualLength: a.length,\n },\n } satisfies ValidationError,\n ]);\n }\n\n const errors: readonly ValidationError[] = Arr.generate(function* () {\n for (const [index, el] of a.entries()) {\n const res = elementType.validate(el);\n\n if (Result.isErr(res)) {\n yield* prependIndexToValidationErrors(res.value, index);\n }\n }\n });\n\n if (Arr.isNonEmpty(errors)) {\n return Result.err(errors);\n }\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return Result.ok(a as unknown as T);\n };\n\n const fill: Type<T>['fill'] = (a) => {\n if (!Arr.isArray(a)) {\n return getDefaultValue();\n }\n\n // Trim down to at most `max`, then pad up to at least `min`.\n const capped = Arr.take(a, asUint32(max));\n\n return capped.length >= min\n ? Arr.map(capped, (el) => elementType.fill(el) satisfies A)\n : Arr.map(\n Arr.seq(asUint32(min)),\n (i) => elementType.fill(capped[i]) satisfies A,\n );\n };\n\n const prune = (a: T): T => a.map((el) => elementType.prune(el));\n\n return {\n typeName,\n get defaultValue() {\n return getDefaultValue();\n },\n fill,\n prune,\n validate,\n is: createIsFn(validate),\n cast: createCastFn(validate),\n assertIs: createAssertFn(validate),\n };\n}\n"],"names":[],"mappings":";;;;;;AA4EO,SAAS,kBAAA,CACd,GAAA,EACA,GAAA,EACA,WAAA,EACA,OAAA,EAM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,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,EAAA,EAAI,WAAW,QAAQ,CAAA;AAAA,IACvB,IAAA,EAAM,aAAa,QAAQ,CAAA;AAAA,IAC3B,QAAA,EAAU,eAAe,QAAQ;AAAA,GACnC;AACF;;;;"}
@@ -0,0 +1,28 @@
1
+ import { Result } from 'ts-data-forge';
2
+ import { type Type } from '../type.mjs';
3
+ import { type ValidationError } from '../utils/index.mjs';
4
+ /**
5
+ * Validates each element of `a` against `elementType`, collecting any element
6
+ * errors with their index prepended. Shared by the length-constrained array
7
+ * validators.
8
+ *
9
+ * @internal Not part of the public package API.
10
+ */
11
+ export declare const validateElements: <A>(a: readonly unknown[], elementType: Type<A>) => Result<readonly A[], readonly ValidationError[]>;
12
+ /**
13
+ * Assembles a structural `Type<readonly A[]>` from the length-specific pieces
14
+ * (`typeName` / `getDefaultValue` / `validate` / `fill`). Shared internally by
15
+ * the length-constrained array validators (`fixedLengthArray` etc.) and the
16
+ * `nonEmptyArray` validator; their outer signatures narrow the structural
17
+ * result to the branded array type.
18
+ *
19
+ * @internal Not part of the public package API.
20
+ */
21
+ export declare const buildType: <Elm, T extends readonly Elm[] = readonly Elm[]>({ typeName, getDefaultValue, validate, fill, elementType, }: Readonly<{
22
+ typeName: string;
23
+ getDefaultValue: () => readonly Elm[];
24
+ validate: (a: unknown) => Result<readonly Elm[], readonly ValidationError[]>;
25
+ fill: (a: unknown) => readonly Elm[];
26
+ elementType: Type<Elm>;
27
+ }>) => Type<T>;
28
+ //# sourceMappingURL=build-type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-type.d.mts","sourceRoot":"","sources":["../../src/array/build-type.mts"],"names":[],"mappings":"AAAA,OAAO,EAAO,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,KAC7B,SAAS,OAAO,EAAE,eACR,IAAI,CAAC,CAAC,CAAC,KACnB,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,eAAe,EAAE,CAiBjD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,EAAE,CAAC,SAAS,SAAS,GAAG,EAAE,GAAG,SAAS,GAAG,EAAE,+DAMrE,QAAQ,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,SAAS,GAAG,EAAE,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC,SAAS,GAAG,EAAE,EAAE,SAAS,eAAe,EAAE,CAAC,CAAC;IAC7E,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,SAAS,GAAG,EAAE,CAAC;IACrC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;CACxB,CAAC,KAAG,IAAI,CAAC,CAAC,CAqBV,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { Arr, Result } from 'ts-data-forge';
2
+ import { createAssertFn } from '../utils/create-assert-fn.mjs';
3
+ import { createCastFn } from '../utils/create-cast-fn.mjs';
4
+ import { createIsFn } from '../utils/create-is-fn.mjs';
5
+ import { prependIndexToValidationErrors } from '../utils/validation-error.mjs';
6
+
7
+ const validateElements = (a, elementType) => {
8
+ const errors = Arr.generate(function* () {
9
+ for (const [index, el] of a.entries()) {
10
+ const res = elementType.validate(el);
11
+ if (Result.isErr(res)) {
12
+ yield* prependIndexToValidationErrors(res.value, index);
13
+ }
14
+ }
15
+ });
16
+ if (Arr.isNonEmpty(errors)) {
17
+ return Result.err(errors);
18
+ }
19
+ return Result.ok(a);
20
+ };
21
+ const buildType = ({
22
+ typeName,
23
+ getDefaultValue,
24
+ validate,
25
+ fill,
26
+ elementType
27
+ }) => {
28
+ const base = {
29
+ typeName,
30
+ get defaultValue() {
31
+ return getDefaultValue();
32
+ },
33
+ fill,
34
+ prune: (a) => a.map((el) => elementType.prune(el)),
35
+ validate,
36
+ is: createIsFn(validate),
37
+ cast: createCastFn(validate),
38
+ assertIs: createAssertFn(validate)
39
+ };
40
+ return base;
41
+ };
42
+
43
+ export { buildType, validateElements };
44
+ //# sourceMappingURL=build-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-type.mjs","sources":["../../src/array/build-type.mts"],"sourcesContent":["import { Arr, Result } from 'ts-data-forge';\nimport { type Type } from '../type.mjs';\nimport {\n createAssertFn,\n createCastFn,\n createIsFn,\n prependIndexToValidationErrors,\n type ValidationError,\n} from '../utils/index.mjs';\n\n/**\n * Validates each element of `a` against `elementType`, collecting any element\n * errors with their index prepended. Shared by the length-constrained array\n * validators.\n *\n * @internal Not part of the public package API.\n */\nexport const validateElements = <A,>(\n a: readonly unknown[],\n elementType: Type<A>,\n): Result<readonly A[], readonly ValidationError[]> => {\n const errors: readonly ValidationError[] = Arr.generate(function* () {\n for (const [index, el] of a.entries()) {\n const res = elementType.validate(el);\n\n if (Result.isErr(res)) {\n yield* prependIndexToValidationErrors(res.value, index);\n }\n }\n });\n\n if (Arr.isNonEmpty(errors)) {\n return Result.err(errors);\n }\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return Result.ok(a as readonly A[]);\n};\n\n/**\n * Assembles a structural `Type<readonly A[]>` from the length-specific pieces\n * (`typeName` / `getDefaultValue` / `validate` / `fill`). Shared internally by\n * the length-constrained array validators (`fixedLengthArray` etc.) and the\n * `nonEmptyArray` validator; their outer signatures narrow the structural\n * result to the branded array type.\n *\n * @internal Not part of the public package API.\n */\nexport const buildType = <Elm, T extends readonly Elm[] = readonly Elm[]>({\n typeName,\n getDefaultValue,\n validate,\n fill,\n elementType,\n}: Readonly<{\n typeName: string;\n getDefaultValue: () => readonly Elm[];\n validate: (a: unknown) => Result<readonly Elm[], readonly ValidationError[]>;\n fill: (a: unknown) => readonly Elm[];\n elementType: Type<Elm>;\n}>): Type<T> => {\n const base: Type<readonly Elm[]> = {\n typeName,\n get defaultValue() {\n return getDefaultValue();\n },\n fill,\n prune: (a) => a.map((el) => elementType.prune(el)),\n validate,\n is: createIsFn(validate),\n cast: createCastFn(validate),\n assertIs: createAssertFn(validate),\n } as const;\n\n // The branded output type `T` (e.g. `NonEmptyArray` / `FixedLengthArray`) is\n // a subtype of the structural `readonly Elm[]` the validator actually\n // produces. The brand is guaranteed by the caller's `validate` / `fill` but\n // cannot be proven structurally, so it is asserted here once, on behalf of\n // every length-constrained array validator, instead of at each call site.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return base as Type<T>;\n};\n"],"names":[],"mappings":";;;;;;AAiBO,MAAM,gBAAA,GAAmB,CAC9B,CAAA,EACA,WAAA,KACqD;AACrD,EAAA,MAAM,MAAA,GAAqC,GAAA,CAAI,QAAA,CAAS,aAAa;AACnE,IAAA,KAAA,MAAW,CAAC,KAAA,EAAO,EAAE,CAAA,IAAK,CAAA,CAAE,SAAQ,EAAG;AACrC,MAAA,MAAM,GAAA,GAAM,WAAA,CAAY,QAAA,CAAS,EAAE,CAAA;AAEnC,MAAA,IAAI,MAAA,CAAO,KAAA,CAAM,GAAG,CAAA,EAAG;AACrB,QAAA,OAAO,8BAAA,CAA+B,GAAA,CAAI,KAAA,EAAO,KAAK,CAAA;AAAA,MACxD;AAAA,IACF;AAAA,EACF,CAAC,CAAA;AAED,EAAA,IAAI,GAAA,CAAI,UAAA,CAAW,MAAM,CAAA,EAAG;AAC1B,IAAA,OAAO,MAAA,CAAO,IAAI,MAAM,CAAA;AAAA,EAC1B;AAGA,EAAA,OAAO,MAAA,CAAO,GAAG,CAAiB,CAAA;AACpC;AAWO,MAAM,YAAY,CAAiD;AAAA,EACxE,QAAA;AAAA,EACA,eAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA,KAMgB;AACd,EAAA,MAAM,IAAA,GAA6B;AAAA,IACjC,QAAA;AAAA,IACA,IAAI,YAAA,GAAe;AACjB,MAAA,OAAO,eAAA,EAAgB;AAAA,IACzB,CAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,EAAO,CAAC,CAAA,KAAM,CAAA,CAAE,GAAA,CAAI,CAAC,EAAA,KAAO,WAAA,CAAY,KAAA,CAAM,EAAE,CAAC,CAAA;AAAA,IACjD,QAAA;AAAA,IACA,EAAA,EAAI,WAAW,QAAQ,CAAA;AAAA,IACvB,IAAA,EAAM,aAAa,QAAQ,CAAA;AAAA,IAC3B,QAAA,EAAU,eAAe,QAAQ;AAAA,GACnC;AAQA,EAAA,OAAO,IAAA;AACT;;;;"}
@@ -0,0 +1,23 @@
1
+ import { type FixedLengthArray, type SupportedLength } from 'ts-type-forge';
2
+ import { type Type } from '../type.mjs';
3
+ export type { FixedLengthArray } from 'ts-type-forge';
4
+ /**
5
+ * Creates a `Type` for a readonly array with exactly `size` elements, typed as
6
+ * the branded {@link FixedLengthArray} instead of the structural tuple type
7
+ * produced by `fixedLengthTuple`.
8
+ *
9
+ * Because the length constraint lives only in the brand, the element type is
10
+ * never expanded into tuple positions, which keeps type-checking cheap even
11
+ * when `A` is a large type. Prefer this over `fixedLengthTuple` when `A` is
12
+ * large; prefer `fixedLengthTuple` when positional element types or a literal
13
+ * `length` are needed.
14
+ */
15
+ export declare function fixedLengthArray<A, N extends SupportedLength>(size: N, elementType: Type<A>, options?: Partial<Readonly<{
16
+ typeName: string;
17
+ defaultValue: FixedLengthArray<N, A>;
18
+ }>>): Type<FixedLengthArray<N, A>>;
19
+ export declare function fixedLengthArray<A>(size: number, elementType: Type<A>, options?: Partial<Readonly<{
20
+ typeName: string;
21
+ defaultValue: readonly A[];
22
+ }>>): Type<readonly A[]>;
23
+ //# sourceMappingURL=fixed-length-array.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-length-array.d.mts","sourceRoot":"","sources":["../../src/array/fixed-length-array.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAOxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,eAAe,EAC3D,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACtC,CAAC,CACH,GACA,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAIhC,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC;CAC5B,CAAC,CACH,GACA,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { memoizeFunction, Arr, asUint32, Result } from 'ts-data-forge';
2
+ import { createPrimitiveValidationError } from '../utils/validation-error.mjs';
3
+ import { buildType, validateElements } from './build-type.mjs';
4
+
5
+ function fixedLengthArray(size, elementType, options) {
6
+ const typeName = options?.typeName ?? `FixedLengthArray<${size}, ${elementType.typeName}>`;
7
+ const getDefaultValue = memoizeFunction(
8
+ () => options?.defaultValue ?? Arr.create(asUint32(size), elementType.defaultValue)
9
+ );
10
+ const validate = (a) => {
11
+ if (!Arr.isArray(a)) {
12
+ return Result.err([
13
+ createPrimitiveValidationError({
14
+ actualValue: a,
15
+ expectedType: "array",
16
+ typeName,
17
+ details: void 0
18
+ })
19
+ ]);
20
+ }
21
+ if (a.length !== size) {
22
+ return Result.err([
23
+ {
24
+ path: [],
25
+ actualValue: a,
26
+ expectedType: typeName,
27
+ typeName,
28
+ details: {
29
+ kind: "array-length",
30
+ expectedLength: size,
31
+ actualLength: a.length
32
+ }
33
+ }
34
+ ]);
35
+ }
36
+ return validateElements(a, elementType);
37
+ };
38
+ const fill = (a) => Arr.isArray(a) ? Arr.map(
39
+ Arr.seq(asUint32(size)),
40
+ (i) => elementType.fill(a[i])
41
+ ) : getDefaultValue();
42
+ return buildType({ typeName, getDefaultValue, validate, fill, elementType });
43
+ }
44
+
45
+ export { fixedLengthArray };
46
+ //# sourceMappingURL=fixed-length-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-length-array.mjs","sources":["../../src/array/fixed-length-array.mts"],"sourcesContent":["import { Arr, asUint32, memoizeFunction, Result } from 'ts-data-forge';\nimport { type FixedLengthArray, type SupportedLength } from 'ts-type-forge';\nimport { type Type } from '../type.mjs';\nimport {\n createPrimitiveValidationError,\n type ValidationError,\n} from '../utils/index.mjs';\nimport { buildType, validateElements } from './build-type.mjs';\n\nexport type { FixedLengthArray } from 'ts-type-forge';\n\n/**\n * Creates a `Type` for a readonly array with exactly `size` elements, typed as\n * the branded {@link FixedLengthArray} instead of the structural tuple type\n * produced by `fixedLengthTuple`.\n *\n * Because the length constraint lives only in the brand, the element type is\n * never expanded into tuple positions, which keeps type-checking cheap even\n * when `A` is a large type. Prefer this over `fixedLengthTuple` when `A` is\n * large; prefer `fixedLengthTuple` when positional element types or a literal\n * `length` are needed.\n */\nexport function fixedLengthArray<A, N extends SupportedLength>(\n size: N,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: FixedLengthArray<N, A>;\n }>\n >,\n): Type<FixedLengthArray<N, A>>;\n\n// For sizes outside `SupportedLength` (`0..2048`) the length cannot be encoded in the brand,\n// so the result length is left unconstrained (`readonly A[]`).\nexport function fixedLengthArray<A>(\n size: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]>;\n\nexport function fixedLengthArray<A>(\n size: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]> {\n type T = readonly A[];\n\n const typeName =\n options?.typeName ?? `FixedLengthArray<${size}, ${elementType.typeName}>`;\n\n const getDefaultValue = memoizeFunction(\n (): T =>\n options?.defaultValue ??\n Arr.create(asUint32(size), elementType.defaultValue),\n );\n\n const validate: Type<T>['validate'] = (a) => {\n if (!Arr.isArray(a)) {\n return Result.err([\n createPrimitiveValidationError({\n actualValue: a,\n expectedType: 'array',\n typeName,\n details: undefined,\n }),\n ]);\n }\n\n if (a.length !== size) {\n return Result.err([\n {\n path: [],\n actualValue: a,\n expectedType: typeName,\n typeName,\n details: {\n kind: 'array-length',\n expectedLength: size,\n actualLength: a.length,\n },\n } satisfies ValidationError,\n ]);\n }\n\n return validateElements(a, elementType);\n };\n\n const fill: Type<T>['fill'] = (a) =>\n Arr.isArray(a)\n ? Arr.map(\n Arr.seq(asUint32(size)),\n (i) => elementType.fill(a[i]) satisfies A,\n )\n : getDefaultValue();\n\n return buildType({ typeName, getDefaultValue, validate, fill, elementType });\n}\n"],"names":[],"mappings":";;;;AA8CO,SAAS,gBAAA,CACd,IAAA,EACA,WAAA,EACA,OAAA,EAMoB;AAGpB,EAAA,MAAM,WACJ,OAAA,EAAS,QAAA,IAAY,oBAAoB,IAAI,CAAA,EAAA,EAAK,YAAY,QAAQ,CAAA,CAAA,CAAA;AAExE,EAAA,MAAM,eAAA,GAAkB,eAAA;AAAA,IACtB,MACE,SAAS,YAAA,IACT,GAAA,CAAI,OAAO,QAAA,CAAS,IAAI,CAAA,EAAG,WAAA,CAAY,YAAY;AAAA,GACvD;AAEA,EAAA,MAAM,QAAA,GAAgC,CAAC,CAAA,KAAM;AAC3C,IAAA,IAAI,CAAC,GAAA,CAAI,OAAA,CAAQ,CAAC,CAAA,EAAG;AACnB,MAAA,OAAO,OAAO,GAAA,CAAI;AAAA,QAChB,8BAAA,CAA+B;AAAA,UAC7B,WAAA,EAAa,CAAA;AAAA,UACb,YAAA,EAAc,OAAA;AAAA,UACd,QAAA;AAAA,UACA,OAAA,EAAS;AAAA,SACV;AAAA,OACF,CAAA;AAAA,IACH;AAEA,IAAA,IAAI,CAAA,CAAE,WAAW,IAAA,EAAM;AACrB,MAAA,OAAO,OAAO,GAAA,CAAI;AAAA,QAChB;AAAA,UACE,MAAM,EAAC;AAAA,UACP,WAAA,EAAa,CAAA;AAAA,UACb,YAAA,EAAc,QAAA;AAAA,UACd,QAAA;AAAA,UACA,OAAA,EAAS;AAAA,YACP,IAAA,EAAM,cAAA;AAAA,YACN,cAAA,EAAgB,IAAA;AAAA,YAChB,cAAc,CAAA,CAAE;AAAA;AAClB;AACF,OACD,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,gBAAA,CAAiB,GAAG,WAAW,CAAA;AAAA,EACxC,CAAA;AAEA,EAAA,MAAM,OAAwB,CAAC,CAAA,KAC7B,IAAI,OAAA,CAAQ,CAAC,IACT,GAAA,CAAI,GAAA;AAAA,IACF,GAAA,CAAI,GAAA,CAAI,QAAA,CAAS,IAAI,CAAC,CAAA;AAAA,IACtB,CAAC,CAAA,KAAM,WAAA,CAAY,IAAA,CAAK,CAAA,CAAE,CAAC,CAAC;AAAA,MAE9B,eAAA,EAAgB;AAEtB,EAAA,OAAO,UAAU,EAAE,QAAA,EAAU,iBAAiB,QAAA,EAAU,IAAA,EAAM,aAAa,CAAA;AAC7E;;;;"}
@@ -0,0 +1,8 @@
1
+ import { type FixedLengthTuple, type StructuralPrefixLength } from 'ts-type-forge';
2
+ import { type Type } from '../type.mjs';
3
+ export type { FixedLengthTuple } from 'ts-type-forge';
4
+ export declare const fixedLengthTuple: <A, N extends StructuralPrefixLength>(size: N, elementType: Type<A>, options?: Partial<Readonly<{
5
+ typeName: string;
6
+ defaultValue: FixedLengthTuple<N, A>;
7
+ }>>) => Type<FixedLengthTuple<N, A>>;
8
+ //# sourceMappingURL=fixed-length-tuple.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-length-tuple.d.mts","sourceRoot":"","sources":["../../src/array/fixed-length-tuple.mts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAUxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAE,CAAC,SAAS,sBAAsB,QAC5D,CAAC,eACM,IAAI,CAAC,CAAC,CAAC,YACV,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACtC,CAAC,CACH,KACA,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAoF7B,CAAC"}
@@ -4,8 +4,8 @@ import { createCastFn } from '../utils/create-cast-fn.mjs';
4
4
  import { createIsFn } from '../utils/create-is-fn.mjs';
5
5
  import { createPrimitiveValidationError, prependIndexToValidationErrors } from '../utils/validation-error.mjs';
6
6
 
7
- const arrayOfLength = (size, elementType, options) => {
8
- const typeName = options?.typeName ?? `ArrayOfLength<${size}, ${elementType.typeName}>`;
7
+ const fixedLengthTuple = (size, elementType, options) => {
8
+ const typeName = options?.typeName ?? `FixedLengthTuple<${size}, ${elementType.typeName}>`;
9
9
  const getDefaultValue = memoizeFunction(
10
10
  () => options?.defaultValue ?? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
11
11
  Arr.create(size, elementType.defaultValue)
@@ -21,7 +21,7 @@ const arrayOfLength = (size, elementType, options) => {
21
21
  })
22
22
  ]);
23
23
  }
24
- if (!Arr.isArrayOfLength(a, size)) {
24
+ if (!Arr.isFixedLengthTuple(a, size)) {
25
25
  return Result.err([
26
26
  {
27
27
  path: [],
@@ -75,5 +75,5 @@ const arrayOfLength = (size, elementType, options) => {
75
75
  };
76
76
  };
77
77
 
78
- export { arrayOfLength };
79
- //# sourceMappingURL=array-of-length.mjs.map
78
+ export { fixedLengthTuple };
79
+ //# sourceMappingURL=fixed-length-tuple.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-length-tuple.mjs","sources":["../../src/array/fixed-length-tuple.mts"],"sourcesContent":["import { Arr, memoizeFunction, Result } from 'ts-data-forge';\nimport {\n type FixedLengthTuple,\n type StructuralPrefixLength,\n} from 'ts-type-forge';\nimport { type Type } from '../type.mjs';\nimport {\n createAssertFn,\n createCastFn,\n createIsFn,\n createPrimitiveValidationError,\n prependIndexToValidationErrors,\n type ValidationError,\n} from '../utils/index.mjs';\n\nexport type { FixedLengthTuple } from 'ts-type-forge';\n\nexport const fixedLengthTuple = <A, N extends StructuralPrefixLength>(\n size: N,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: FixedLengthTuple<N, A>;\n }>\n >,\n): Type<FixedLengthTuple<N, A>> => {\n type T = FixedLengthTuple<N, A>;\n\n const typeName =\n options?.typeName ?? `FixedLengthTuple<${size}, ${elementType.typeName}>`;\n\n const getDefaultValue = memoizeFunction(\n (): T =>\n options?.defaultValue ??\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (Arr.create(size, elementType.defaultValue) as T),\n );\n\n const validate: Type<T>['validate'] = (a) => {\n if (!Arr.isArray(a)) {\n return Result.err([\n createPrimitiveValidationError({\n actualValue: a,\n expectedType: 'array',\n typeName,\n details: undefined,\n }),\n ]);\n }\n\n if (!Arr.isFixedLengthTuple(a, size)) {\n return Result.err([\n {\n path: [],\n actualValue: a,\n expectedType: typeName,\n typeName,\n details: {\n kind: 'array-length',\n expectedLength: size,\n actualLength: a.length,\n },\n } satisfies ValidationError,\n ]);\n }\n\n const errors: readonly ValidationError[] = Arr.generate(function* () {\n for (const [index, el] of a.entries()) {\n const res = elementType.validate(el);\n\n if (Result.isErr(res)) {\n yield* prependIndexToValidationErrors(res.value, index);\n }\n }\n });\n\n if (Arr.isNonEmpty(errors)) {\n return Result.err(errors);\n }\n\n return Result.ok(a);\n };\n\n const fill: Type<T>['fill'] = (a) =>\n !Arr.isArray(a)\n ? getDefaultValue()\n : // TODO: remove as\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (Arr.map(\n Arr.seq(size),\n (i) => elementType.fill(a[i]) satisfies A,\n ) as T);\n\n const prune = (a: T): T =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Arr.map(a, (el) => elementType.prune(el)) as T;\n\n return {\n typeName,\n get defaultValue() {\n return getDefaultValue();\n },\n fill,\n prune,\n validate,\n is: createIsFn(validate),\n cast: createCastFn(validate),\n assertIs: createAssertFn(validate),\n };\n};\n"],"names":[],"mappings":";;;;;;AAiBO,MAAM,gBAAA,GAAmB,CAC9B,IAAA,EACA,WAAA,EACA,OAAA,KAMiC;AAGjC,EAAA,MAAM,WACJ,OAAA,EAAS,QAAA,IAAY,oBAAoB,IAAI,CAAA,EAAA,EAAK,YAAY,QAAQ,CAAA,CAAA,CAAA;AAExE,EAAA,MAAM,eAAA,GAAkB,eAAA;AAAA,IACtB,MACE,OAAA,EAAS,YAAA;AAAA,IAER,GAAA,CAAI,MAAA,CAAO,IAAA,EAAM,WAAA,CAAY,YAAY;AAAA,GAC9C;AAEA,EAAA,MAAM,QAAA,GAAgC,CAAC,CAAA,KAAM;AAC3C,IAAA,IAAI,CAAC,GAAA,CAAI,OAAA,CAAQ,CAAC,CAAA,EAAG;AACnB,MAAA,OAAO,OAAO,GAAA,CAAI;AAAA,QAChB,8BAAA,CAA+B;AAAA,UAC7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,GAAA,CAAI,IAAI,IAAI,CAAA;AAAA,MACZ,CAAC,CAAA,KAAM,WAAA,CAAY,IAAA,CAAK,CAAA,CAAE,CAAC,CAAC;AAAA;AAC9B,GAAA;AAEN,EAAA,MAAM,QAAQ,CAAC,CAAA;AAAA;AAAA,IAEb,GAAA,CAAI,IAAI,CAAA,EAAG,CAAC,OAAO,WAAA,CAAY,KAAA,CAAM,EAAE,CAAC;AAAA,GAAA;AAE1C,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,IAAI,YAAA,GAAe;AACjB,MAAA,OAAO,eAAA,EAAgB;AAAA,IACzB,CAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,EAAA,EAAI,WAAW,QAAQ,CAAA;AAAA,IACvB,IAAA,EAAM,aAAa,QAAQ,CAAA;AAAA,IAC3B,QAAA,EAAU,eAAe,QAAQ;AAAA,GACnC;AACF;;;;"}
@@ -1,8 +1,12 @@
1
- export * from './array-at-least-length.mjs';
2
- export * from './array-at-most-length.mjs';
3
- export * from './array-bounded-length.mjs';
4
- export * from './array-of-length.mjs';
5
1
  export * from './array.mjs';
2
+ export * from './bounded-length-array.mjs';
3
+ export * from './bounded-length-tuple.mjs';
4
+ export * from './fixed-length-array.mjs';
5
+ export * from './fixed-length-tuple.mjs';
6
+ export * from './max-length-array.mjs';
7
+ export * from './max-length-tuple.mjs';
8
+ export * from './min-length-array.mjs';
9
+ export * from './min-length-tuple.mjs';
6
10
  export * from './non-empty-array.mjs';
7
11
  export * from './tuple.mjs';
8
12
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/array/index.mts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/array/index.mts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
@@ -1,8 +1,12 @@
1
- export { arrayAtLeastLength } from './array-at-least-length.mjs';
2
- export { arrayAtMostLength } from './array-at-most-length.mjs';
3
- export { arrayBoundedLength } from './array-bounded-length.mjs';
4
- export { arrayOfLength } from './array-of-length.mjs';
5
1
  export { array } from './array.mjs';
2
+ export { boundedLengthArray } from './bounded-length-array.mjs';
3
+ export { boundedLengthTuple } from './bounded-length-tuple.mjs';
4
+ export { fixedLengthArray } from './fixed-length-array.mjs';
5
+ export { fixedLengthTuple } from './fixed-length-tuple.mjs';
6
+ export { maxLengthArray } from './max-length-array.mjs';
7
+ export { maxLengthTuple } from './max-length-tuple.mjs';
8
+ export { minLengthArray } from './min-length-array.mjs';
9
+ export { minLengthTuple } from './min-length-tuple.mjs';
6
10
  export { nonEmptyArray } from './non-empty-array.mjs';
7
11
  export { tuple } from './tuple.mjs';
8
12
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,21 @@
1
+ import { type MaxLengthArray, type SupportedLength } from 'ts-type-forge';
2
+ import { type Type } from '../type.mjs';
3
+ export type { MaxLengthArray } from 'ts-type-forge';
4
+ /**
5
+ * Creates a `Type` for a readonly array with at most `maxLength` elements,
6
+ * typed as the branded {@link MaxLengthArray} instead of the union of tuple
7
+ * types produced by `maxLengthTuple`.
8
+ *
9
+ * Because the length constraint lives only in the brand, no union of tuples
10
+ * of the element type is ever constructed, which keeps type-checking cheap
11
+ * even when `A` is a large type.
12
+ */
13
+ export declare function maxLengthArray<A, N extends SupportedLength>(maxLength: N, elementType: Type<A>, options?: Partial<Readonly<{
14
+ typeName: string;
15
+ defaultValue: MaxLengthArray<N, A>;
16
+ }>>): Type<MaxLengthArray<N, A>>;
17
+ export declare function maxLengthArray<A>(maxLength: number, elementType: Type<A>, options?: Partial<Readonly<{
18
+ typeName: string;
19
+ defaultValue: readonly A[];
20
+ }>>): Type<readonly A[]>;
21
+ //# sourceMappingURL=max-length-array.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max-length-array.d.mts","sourceRoot":"","sources":["../../src/array/max-length-array.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAOxC,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,eAAe,EACzD,SAAS,EAAE,CAAC,EACZ,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACpC,CAAC,CACH,GACA,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAI9B,wBAAgB,cAAc,CAAC,CAAC,EAC9B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC;CAC5B,CAAC,CACH,GACA,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { memoizeFunction, Arr, Result, asUint32 } from 'ts-data-forge';
2
+ import { createPrimitiveValidationError } from '../utils/validation-error.mjs';
3
+ import { buildType, validateElements } from './build-type.mjs';
4
+
5
+ function maxLengthArray(maxLength, elementType, options) {
6
+ const typeName = options?.typeName ?? `MaxLengthArray<${maxLength}, ${elementType.typeName}>`;
7
+ const getDefaultValue = memoizeFunction(
8
+ () => options?.defaultValue ?? // The empty array is the shortest value satisfying `length <= maxLength`.
9
+ Arr.create(0, elementType.defaultValue)
10
+ );
11
+ const validate = (a) => {
12
+ if (!Arr.isArray(a)) {
13
+ return Result.err([
14
+ createPrimitiveValidationError({
15
+ actualValue: a,
16
+ expectedType: "array",
17
+ typeName,
18
+ details: void 0
19
+ })
20
+ ]);
21
+ }
22
+ if (a.length > maxLength) {
23
+ return Result.err([
24
+ {
25
+ path: [],
26
+ actualValue: a,
27
+ expectedType: typeName,
28
+ typeName,
29
+ details: {
30
+ kind: "array-max-length",
31
+ maxLength,
32
+ actualLength: a.length
33
+ }
34
+ }
35
+ ]);
36
+ }
37
+ return validateElements(a, elementType);
38
+ };
39
+ const fill = (a) => Arr.isArray(a) ? (
40
+ // Keep the input but trim down to at most `maxLength` elements.
41
+ Arr.map(
42
+ Arr.take(a, asUint32(maxLength)),
43
+ (el) => elementType.fill(el)
44
+ )
45
+ ) : getDefaultValue();
46
+ return buildType({ typeName, getDefaultValue, validate, fill, elementType });
47
+ }
48
+
49
+ export { maxLengthArray };
50
+ //# sourceMappingURL=max-length-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max-length-array.mjs","sources":["../../src/array/max-length-array.mts"],"sourcesContent":["import { Arr, asUint32, memoizeFunction, Result } from 'ts-data-forge';\nimport { type MaxLengthArray, type SupportedLength } from 'ts-type-forge';\nimport { type Type } from '../type.mjs';\nimport {\n createPrimitiveValidationError,\n type ValidationError,\n} from '../utils/index.mjs';\nimport { buildType, validateElements } from './build-type.mjs';\n\nexport type { MaxLengthArray } from 'ts-type-forge';\n\n/**\n * Creates a `Type` for a readonly array with at most `maxLength` elements,\n * typed as the branded {@link MaxLengthArray} instead of the union of tuple\n * types produced by `maxLengthTuple`.\n *\n * Because the length constraint lives only in the brand, no union of tuples\n * of the element type is ever constructed, which keeps type-checking cheap\n * even when `A` is a large type.\n */\nexport function maxLengthArray<A, N extends SupportedLength>(\n maxLength: N,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: MaxLengthArray<N, A>;\n }>\n >,\n): Type<MaxLengthArray<N, A>>;\n\n// For bounds outside `SupportedLength` (`0..2048`) the length cannot be encoded in the brand,\n// so the result length is left unconstrained (`readonly A[]`).\nexport function maxLengthArray<A>(\n maxLength: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]>;\n\nexport function maxLengthArray<A>(\n maxLength: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]> {\n type T = readonly A[];\n\n const typeName =\n options?.typeName ??\n `MaxLengthArray<${maxLength}, ${elementType.typeName}>`;\n\n const getDefaultValue = memoizeFunction(\n (): T =>\n options?.defaultValue ??\n // The empty array is the shortest value satisfying `length <= maxLength`.\n Arr.create(0, elementType.defaultValue),\n );\n\n const validate: Type<T>['validate'] = (a) => {\n if (!Arr.isArray(a)) {\n return Result.err([\n createPrimitiveValidationError({\n actualValue: a,\n expectedType: 'array',\n typeName,\n details: undefined,\n }),\n ]);\n }\n\n if (a.length > maxLength) {\n return Result.err([\n {\n path: [],\n actualValue: a,\n expectedType: typeName,\n typeName,\n details: {\n kind: 'array-max-length',\n maxLength,\n actualLength: a.length,\n },\n } satisfies ValidationError,\n ]);\n }\n\n return validateElements(a, elementType);\n };\n\n const fill: Type<T>['fill'] = (a) =>\n Arr.isArray(a)\n ? // Keep the input but trim down to at most `maxLength` elements.\n Arr.map(\n Arr.take(a, asUint32(maxLength)),\n (el) => elementType.fill(el) satisfies A,\n )\n : getDefaultValue();\n\n return buildType({ typeName, getDefaultValue, validate, fill, elementType });\n}\n"],"names":[],"mappings":";;;;AA4CO,SAAS,cAAA,CACd,SAAA,EACA,WAAA,EACA,OAAA,EAMoB;AAGpB,EAAA,MAAM,WACJ,OAAA,EAAS,QAAA,IACT,kBAAkB,SAAS,CAAA,EAAA,EAAK,YAAY,QAAQ,CAAA,CAAA,CAAA;AAEtD,EAAA,MAAM,eAAA,GAAkB,eAAA;AAAA,IACtB,MACE,OAAA,EAAS,YAAA;AAAA,IAET,GAAA,CAAI,MAAA,CAAO,CAAA,EAAG,WAAA,CAAY,YAAY;AAAA,GAC1C;AAEA,EAAA,MAAM,QAAA,GAAgC,CAAC,CAAA,KAAM;AAC3C,IAAA,IAAI,CAAC,GAAA,CAAI,OAAA,CAAQ,CAAC,CAAA,EAAG;AACnB,MAAA,OAAO,OAAO,GAAA,CAAI;AAAA,QAChB,8BAAA,CAA+B;AAAA,UAC7B,WAAA,EAAa,CAAA;AAAA,UACb,YAAA,EAAc,OAAA;AAAA,UACd,QAAA;AAAA,UACA,OAAA,EAAS;AAAA,SACV;AAAA,OACF,CAAA;AAAA,IACH;AAEA,IAAA,IAAI,CAAA,CAAE,SAAS,SAAA,EAAW;AACxB,MAAA,OAAO,OAAO,GAAA,CAAI;AAAA,QAChB;AAAA,UACE,MAAM,EAAC;AAAA,UACP,WAAA,EAAa,CAAA;AAAA,UACb,YAAA,EAAc,QAAA;AAAA,UACd,QAAA;AAAA,UACA,OAAA,EAAS;AAAA,YACP,IAAA,EAAM,kBAAA;AAAA,YACN,SAAA;AAAA,YACA,cAAc,CAAA,CAAE;AAAA;AAClB;AACF,OACD,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,gBAAA,CAAiB,GAAG,WAAW,CAAA;AAAA,EACxC,CAAA;AAEA,EAAA,MAAM,IAAA,GAAwB,CAAC,CAAA,KAC7B,GAAA,CAAI,QAAQ,CAAC,CAAA;AAAA;AAAA,IAET,GAAA,CAAI,GAAA;AAAA,MACF,GAAA,CAAI,IAAA,CAAK,CAAA,EAAG,QAAA,CAAS,SAAS,CAAC,CAAA;AAAA,MAC/B,CAAC,EAAA,KAAO,WAAA,CAAY,IAAA,CAAK,EAAE;AAAA;AAC7B,MACA,eAAA,EAAgB;AAEtB,EAAA,OAAO,UAAU,EAAE,QAAA,EAAU,iBAAiB,QAAA,EAAU,IAAA,EAAM,aAAa,CAAA;AAC7E;;;;"}
@@ -0,0 +1,12 @@
1
+ import { type MaxLengthTuple, type StructuralPrefixLength } from 'ts-type-forge';
2
+ import { type Type } from '../type.mjs';
3
+ export type { MaxLengthTuple } from 'ts-type-forge';
4
+ export declare function maxLengthTuple<A, N extends StructuralPrefixLength>(size: N, elementType: Type<A>, options?: Partial<Readonly<{
5
+ typeName: string;
6
+ defaultValue: MaxLengthTuple<N, A>;
7
+ }>>): Type<MaxLengthTuple<N, A>>;
8
+ export declare function maxLengthTuple<A>(size: number, elementType: Type<A>, options?: Partial<Readonly<{
9
+ typeName: string;
10
+ defaultValue: readonly A[];
11
+ }>>): Type<readonly A[]>;
12
+ //# sourceMappingURL=max-length-tuple.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max-length-tuple.d.mts","sourceRoot":"","sources":["../../src/array/max-length-tuple.mts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAUxC,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,sBAAsB,EAChE,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACpC,CAAC,CACH,GACA,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAI9B,wBAAgB,cAAc,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,OAAO,CACf,QAAQ,CAAC;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC;CAC5B,CAAC,CACH,GACA,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC"}
@@ -4,8 +4,8 @@ import { createCastFn } from '../utils/create-cast-fn.mjs';
4
4
  import { createIsFn } from '../utils/create-is-fn.mjs';
5
5
  import { createPrimitiveValidationError, prependIndexToValidationErrors } from '../utils/validation-error.mjs';
6
6
 
7
- function arrayAtMostLength(size, elementType, options) {
8
- const typeName = options?.typeName ?? `ArrayAtMostLen<${size}, ${elementType.typeName}>`;
7
+ function maxLengthTuple(size, elementType, options) {
8
+ const typeName = options?.typeName ?? `MaxLengthTuple<${size}, ${elementType.typeName}>`;
9
9
  const getDefaultValue = memoizeFunction(
10
10
  () => options?.defaultValue ?? // The empty array is the shortest value satisfying `length <= size`.
11
11
  Arr.create(0, elementType.defaultValue)
@@ -71,5 +71,5 @@ function arrayAtMostLength(size, elementType, options) {
71
71
  };
72
72
  }
73
73
 
74
- export { arrayAtMostLength };
75
- //# sourceMappingURL=array-at-most-length.mjs.map
74
+ export { maxLengthTuple };
75
+ //# sourceMappingURL=max-length-tuple.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max-length-tuple.mjs","sources":["../../src/array/max-length-tuple.mts"],"sourcesContent":["import { Arr, asUint32, memoizeFunction, Result } from 'ts-data-forge';\nimport {\n type MaxLengthTuple,\n type StructuralPrefixLength,\n} from 'ts-type-forge';\nimport { type Type } from '../type.mjs';\nimport {\n createAssertFn,\n createCastFn,\n createIsFn,\n createPrimitiveValidationError,\n prependIndexToValidationErrors,\n type ValidationError,\n} from '../utils/index.mjs';\n\nexport type { MaxLengthTuple } from 'ts-type-forge';\n\nexport function maxLengthTuple<A, N extends StructuralPrefixLength>(\n size: N,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: MaxLengthTuple<N, A>;\n }>\n >,\n): Type<MaxLengthTuple<N, A>>;\n\n// For sizes outside `StructuralPrefixLength` (`0..10`) the exact length cannot be encoded in the type,\n// so the result length is left unconstrained (`readonly A[]`).\nexport function maxLengthTuple<A>(\n size: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]>;\n\nexport function maxLengthTuple<A>(\n size: number,\n elementType: Type<A>,\n options?: Partial<\n Readonly<{\n typeName: string;\n defaultValue: readonly A[];\n }>\n >,\n): Type<readonly A[]> {\n type T = readonly A[];\n\n const typeName =\n options?.typeName ?? `MaxLengthTuple<${size}, ${elementType.typeName}>`;\n\n const getDefaultValue = memoizeFunction(\n (): T =>\n options?.defaultValue ??\n // The empty array is the shortest value satisfying `length <= size`.\n Arr.create(0, elementType.defaultValue),\n );\n\n const validate: Type<T>['validate'] = (a) => {\n if (!Arr.isArray(a)) {\n return Result.err([\n createPrimitiveValidationError({\n actualValue: a,\n expectedType: 'array',\n typeName,\n details: undefined,\n }),\n ]);\n }\n\n if (a.length > size) {\n return Result.err([\n {\n path: [],\n actualValue: a,\n expectedType: typeName,\n typeName,\n details: {\n kind: 'array-max-length',\n maxLength: size,\n actualLength: a.length,\n },\n } satisfies ValidationError,\n ]);\n }\n\n const errors: readonly ValidationError[] = Arr.generate(function* () {\n for (const [index, el] of a.entries()) {\n const res = elementType.validate(el);\n\n if (Result.isErr(res)) {\n yield* prependIndexToValidationErrors(res.value, index);\n }\n }\n });\n\n if (Arr.isNonEmpty(errors)) {\n return Result.err(errors);\n }\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return Result.ok(a as unknown as T);\n };\n\n const fill: Type<T>['fill'] = (a) =>\n Arr.isArray(a)\n ? // Keep the input but trim down to at most `size` elements.\n Arr.map(\n Arr.take(a, asUint32(size)),\n (el) => elementType.fill(el) satisfies A,\n )\n : getDefaultValue();\n\n const prune = (a: T): T => a.map((el) => elementType.prune(el));\n\n return {\n typeName,\n get defaultValue() {\n return getDefaultValue();\n },\n fill,\n prune,\n validate,\n is: createIsFn(validate),\n cast: createCastFn(validate),\n assertIs: createAssertFn(validate),\n };\n}\n"],"names":[],"mappings":";;;;;;AAyCO,SAAS,cAAA,CACd,IAAA,EACA,WAAA,EACA,OAAA,EAMoB;AAGpB,EAAA,MAAM,WACJ,OAAA,EAAS,QAAA,IAAY,kBAAkB,IAAI,CAAA,EAAA,EAAK,YAAY,QAAQ,CAAA,CAAA,CAAA;AAEtE,EAAA,MAAM,eAAA,GAAkB,eAAA;AAAA,IACtB,MACE,OAAA,EAAS,YAAA;AAAA,IAET,GAAA,CAAI,MAAA,CAAO,CAAA,EAAG,WAAA,CAAY,YAAY;AAAA,GAC1C;AAEA,EAAA,MAAM,QAAA,GAAgC,CAAC,CAAA,KAAM;AAC3C,IAAA,IAAI,CAAC,GAAA,CAAI,OAAA,CAAQ,CAAC,CAAA,EAAG;AACnB,MAAA,OAAO,OAAO,GAAA,CAAI;AAAA,QAChB,8BAAA,CAA+B;AAAA,UAC7B,WAAA,EAAa,CAAA;AAAA,UACb,YAAA,EAAc,OAAA;AAAA,UACd,QAAA;AAAA,UACA,OAAA,EAAS;AAAA,SACV;AAAA,OAC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