ts-data-forge 14.7.0 → 14.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts +36 -6
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +4 -0
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts +26 -6
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.d.mts.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +4 -0
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/array/impl/array-utils-length-bounded-array-cast.mts +36 -6
- package/src/array/impl/array-utils-length-bounded-tuple-cast.mts +26 -6
- package/src/index.mts +2 -0
|
@@ -19,13 +19,21 @@ import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, ty
|
|
|
19
19
|
* const rgb = Arr.asFixedLengthArray(3, [255, 128, 0]);
|
|
20
20
|
*
|
|
21
21
|
* const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)
|
|
22
|
+
*
|
|
22
23
|
* const red: number = rgb[0]; // OK — no `undefined`
|
|
23
24
|
*
|
|
24
25
|
* // curried version
|
|
25
26
|
* const asRgb = Arr.asFixedLengthArray(3);
|
|
27
|
+
*
|
|
26
28
|
* const green = asRgb([0, 255, 0]);
|
|
27
29
|
*
|
|
28
|
-
*
|
|
30
|
+
* assert.deepStrictEqual(Array.from(atMost5), [255, 128, 0]);
|
|
31
|
+
*
|
|
32
|
+
* assert.strictEqual(red, 255);
|
|
33
|
+
*
|
|
34
|
+
* assert.deepStrictEqual(green, [0, 255, 0]);
|
|
35
|
+
*
|
|
36
|
+
* assert.throws(() => Arr.asFixedLengthArray(3, [255, 128]), TypeError);
|
|
29
37
|
* ```
|
|
30
38
|
*
|
|
31
39
|
* @template Length - The exact number of elements.
|
|
@@ -57,13 +65,21 @@ export declare function asFixedLengthArray<Length extends SupportedLength>(lengt
|
|
|
57
65
|
* const history = Arr.asMinLengthArray(3, [0, 1, 2, 3]);
|
|
58
66
|
*
|
|
59
67
|
* const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)
|
|
68
|
+
*
|
|
60
69
|
* const first: number = history[0]; // OK — no `undefined`
|
|
61
70
|
*
|
|
62
71
|
* // curried version
|
|
63
72
|
* const asHistory = Arr.asMinLengthArray(3);
|
|
73
|
+
*
|
|
64
74
|
* const next = asHistory([4, 5, 6, 7]);
|
|
65
75
|
*
|
|
66
|
-
*
|
|
76
|
+
* assert.deepStrictEqual(Array.from(nonEmpty), [0, 1, 2, 3]);
|
|
77
|
+
*
|
|
78
|
+
* assert.strictEqual(first, 0);
|
|
79
|
+
*
|
|
80
|
+
* assert.deepStrictEqual(next, [4, 5, 6, 7]);
|
|
81
|
+
*
|
|
82
|
+
* assert.throws(() => Arr.asMinLengthArray(3, [0]), TypeError);
|
|
67
83
|
* ```
|
|
68
84
|
*
|
|
69
85
|
* @template MinLength - The minimum number of elements (inclusive).
|
|
@@ -96,9 +112,14 @@ export declare function asMinLengthArray<MinLength extends SupportedLength>(minL
|
|
|
96
112
|
*
|
|
97
113
|
* // curried version
|
|
98
114
|
* const asTags = Arr.asMaxLengthArray(8);
|
|
115
|
+
*
|
|
99
116
|
* const more = asTags(['d', 'e']);
|
|
100
117
|
*
|
|
101
|
-
*
|
|
118
|
+
* assert.deepStrictEqual(Array.from(relaxed), ['a', 'b', 'c']);
|
|
119
|
+
*
|
|
120
|
+
* assert.deepStrictEqual(more, ['d', 'e']);
|
|
121
|
+
*
|
|
122
|
+
* assert.throws(() => Arr.asMaxLengthArray(2, ['a', 'b', 'c']), TypeError);
|
|
102
123
|
* ```
|
|
103
124
|
*
|
|
104
125
|
* @template MaxLength - The maximum number of elements (inclusive).
|
|
@@ -133,9 +154,14 @@ export declare function asMaxLengthArray<MaxLength extends SupportedLength>(maxL
|
|
|
133
154
|
*
|
|
134
155
|
* // curried version
|
|
135
156
|
* const asSelection = Arr.asBoundedLengthArray(1, 5);
|
|
157
|
+
*
|
|
136
158
|
* const next = asSelection([4, 5]);
|
|
137
159
|
*
|
|
138
|
-
*
|
|
160
|
+
* assert.deepStrictEqual(Array.from(relaxed), [1, 2, 3]);
|
|
161
|
+
*
|
|
162
|
+
* assert.deepStrictEqual(next, [4, 5]);
|
|
163
|
+
*
|
|
164
|
+
* assert.throws(() => Arr.asBoundedLengthArray(1, 5, []), TypeError);
|
|
139
165
|
* ```
|
|
140
166
|
*
|
|
141
167
|
* @template MinLength - The minimum number of elements (inclusive).
|
|
@@ -165,7 +191,9 @@ export declare function asBoundedLengthArray<MinLength extends SupportedLength,
|
|
|
165
191
|
*
|
|
166
192
|
* const atMost5: MaxLengthArray<5, never> = nothing; // OK (0 <= 5)
|
|
167
193
|
*
|
|
168
|
-
*
|
|
194
|
+
* assert.deepStrictEqual(Array.from(atMost5), []);
|
|
195
|
+
*
|
|
196
|
+
* assert.throws(() => Arr.asEmptyArray([1]), TypeError);
|
|
169
197
|
* ```
|
|
170
198
|
*
|
|
171
199
|
* @template Xs - The input array type (tuple types are preserved).
|
|
@@ -192,7 +220,9 @@ export declare const asEmptyArray: <Xs extends readonly unknown[]>(xs: Xs) => Fi
|
|
|
192
220
|
*
|
|
193
221
|
* const first: number = history[0]; // OK — no `undefined`
|
|
194
222
|
*
|
|
195
|
-
*
|
|
223
|
+
* assert.strictEqual(first, 0);
|
|
224
|
+
*
|
|
225
|
+
* assert.throws(() => Arr.asNonEmptyArray([]), TypeError);
|
|
196
226
|
* ```
|
|
197
227
|
*
|
|
198
228
|
* @template Xs - The input array type (tuple types are preserved).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-length-bounded-array-cast.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAQvB
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-array-cast.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAQvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,SAAS,eAAe,EAC9B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAGrE,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,eAAe,EAC/D,MAAM,EAAE,MAAM,GACb,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAC/B,EAAE,EAAE,EAAE,KACH,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AA+B/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,SAAS,eAAe,EACjC,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,GAAG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,GACnB,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAC/B,EAAE,EAAE,EAAE,KACH,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAoC/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,GAAI,EAAE,SAAS,SAAS,OAAO,EAAE,MACpD,EAAE,KACL,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,GAAI,EAAE,SAAS,SAAS,OAAO,EAAE,MACvD,EAAE,KACL,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAM9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-length-bounded-array-cast.mjs","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"names":[],"mappings":"AAQA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-array-cast.mjs","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"names":[],"mappings":"AAQA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,8CAA8C,CAAC;AA0DtD,MAAM,UAAU,kBAAkB,CAChC,GAAG,IAEmC;IAEtC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC;YACJ,OAAO,sBAAsB,CAAC,GAAG,IAAI,CAAC,CAAC;QAEzC,KAAK,CAAC;YACJ,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC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QAC/B,MAAM,IAAI,SAAS,CACjB,mDAAmD,EAAE,CAAC,MAAM,EAAE,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,EAAM,EAC0B,EAAE;IAClC,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
|
|
@@ -23,7 +23,11 @@ import { type SizeType } from '../../types.mjs';
|
|
|
23
23
|
* // curried version
|
|
24
24
|
* const asRgb = Arr.asFixedLengthTuple(3);
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* assert.strictEqual(red, 255);
|
|
27
|
+
*
|
|
28
|
+
* assert.deepStrictEqual(asRgb([0, 255, 0]), [0, 255, 0]);
|
|
29
|
+
*
|
|
30
|
+
* assert.throws(() => Arr.asFixedLengthTuple(3, [255, 128]), TypeError);
|
|
27
31
|
* ```
|
|
28
32
|
*
|
|
29
33
|
* @template Length - The exact number of elements.
|
|
@@ -52,7 +56,11 @@ export declare function asFixedLengthTuple<Length extends SizeType.ArgArr>(lengt
|
|
|
52
56
|
* // curried version
|
|
53
57
|
* const asHistory = Arr.asMinLengthTuple(3);
|
|
54
58
|
*
|
|
55
|
-
*
|
|
59
|
+
* assert.strictEqual(first, 0);
|
|
60
|
+
*
|
|
61
|
+
* assert.deepStrictEqual(asHistory([4, 5, 6]), [4, 5, 6]);
|
|
62
|
+
*
|
|
63
|
+
* assert.throws(() => Arr.asMinLengthTuple(3, [0, 1]), TypeError);
|
|
56
64
|
* ```
|
|
57
65
|
*
|
|
58
66
|
* @template MinLength - The minimum number of elements (inclusive).
|
|
@@ -79,7 +87,11 @@ export declare function asMinLengthTuple<MinLength extends SizeType.ArgArr>(minL
|
|
|
79
87
|
* // curried version
|
|
80
88
|
* const asTags = Arr.asMaxLengthTuple(8);
|
|
81
89
|
*
|
|
82
|
-
*
|
|
90
|
+
* assert.deepStrictEqual(tags, ['a', 'b', 'c']);
|
|
91
|
+
*
|
|
92
|
+
* assert.deepStrictEqual(asTags(['d', 'e']), ['d', 'e']);
|
|
93
|
+
*
|
|
94
|
+
* assert.throws(() => Arr.asMaxLengthTuple(2, ['a', 'b', 'c']), TypeError);
|
|
83
95
|
* ```
|
|
84
96
|
*
|
|
85
97
|
* @template MaxLength - The maximum number of elements (inclusive).
|
|
@@ -106,7 +118,11 @@ export declare function asMaxLengthTuple<MaxLength extends SizeType.ArgArr>(maxL
|
|
|
106
118
|
* // curried version
|
|
107
119
|
* const asSelection = Arr.asBoundedLengthTuple(1, 5);
|
|
108
120
|
*
|
|
109
|
-
*
|
|
121
|
+
* assert.deepStrictEqual(selection, [1, 2, 3]);
|
|
122
|
+
*
|
|
123
|
+
* assert.deepStrictEqual(asSelection([4, 5]), [4, 5]);
|
|
124
|
+
*
|
|
125
|
+
* assert.throws(() => Arr.asBoundedLengthTuple(1, 2, [1, 2, 3]), TypeError);
|
|
110
126
|
* ```
|
|
111
127
|
*
|
|
112
128
|
* @template Min - The minimum number of elements (inclusive).
|
|
@@ -132,7 +148,9 @@ export declare function asBoundedLengthTuple<Min extends SizeType.ArgArr, Max ex
|
|
|
132
148
|
* ```ts
|
|
133
149
|
* const nothing = Arr.asEmptyTuple([]);
|
|
134
150
|
*
|
|
135
|
-
*
|
|
151
|
+
* assert.deepStrictEqual(nothing, []);
|
|
152
|
+
*
|
|
153
|
+
* assert.throws(() => Arr.asEmptyTuple([1]), TypeError);
|
|
136
154
|
* ```
|
|
137
155
|
*
|
|
138
156
|
* @template Xs - The input array type (tuple types are preserved).
|
|
@@ -155,7 +173,9 @@ export declare const asEmptyTuple: <Xs extends readonly unknown[]>(xs: Xs) => re
|
|
|
155
173
|
*
|
|
156
174
|
* const first: number = values[0]; // OK — no `undefined`
|
|
157
175
|
*
|
|
158
|
-
*
|
|
176
|
+
* assert.strictEqual(first, 1);
|
|
177
|
+
*
|
|
178
|
+
* assert.throws(() => Arr.asNonEmptyTuple([]), TypeError);
|
|
159
179
|
* ```
|
|
160
180
|
*
|
|
161
181
|
* @template Xs - The input array type (tuple types are preserved).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-length-bounded-tuple-cast.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-tuple-cast.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAShD
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-tuple-cast.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-tuple-cast.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAShD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,SAAS,QAAQ,CAAC,MAAM,EAC9B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAGrE,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,QAAQ,CAAC,MAAM,EAC/D,MAAM,EAAE,MAAM,GACb,CAAC,EAAE,SAAS,SAAS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,EAC3B,GAAG,SAAS,QAAQ,CAAC,MAAM,EAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAG7E,wBAAgB,oBAAoB,CAClC,GAAG,SAAS,QAAQ,CAAC,MAAM,EAC3B,GAAG,SAAS,QAAQ,CAAC,MAAM,EAE3B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,GACP,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAC/B,EAAE,EAAE,EAAE,KACH,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAoCnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,YAAY,GAAI,EAAE,SAAS,SAAS,OAAO,EAAE,MACpD,EAAE,KACL,SAAS,EAAE,GAAG,EAQhB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,GAAI,EAAE,SAAS,SAAS,OAAO,EAAE,MACvD,EAAE,KACL,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAMlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-length-bounded-tuple-cast.mjs","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-tuple-cast.mts"],"names":[],"mappings":"AAOA,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-tuple-cast.mjs","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-tuple-c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E,EAAE,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CACjB,mCAAmC,GAAG,KAAK,GAAG,6BAA6B,YAAY,EAAE,CAC1F,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,EAAM,EACY,EAAE;IACpB,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CACjB,mDAAmD,EAAE,CAAC,MAAM,EAAE,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,EAAM,EAC8B,EAAE;IACtC,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from './array/index.mjs';
|
|
1
2
|
export * from './collections/index.mjs';
|
|
2
3
|
export * from './expect-type.mjs';
|
|
4
|
+
export * from './functional/index.mjs';
|
|
3
5
|
export * from './guard/index.mjs';
|
|
4
6
|
export * from './iterator/index.mjs';
|
|
5
7
|
export * from './json/index.mjs';
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from './array/index.mjs';
|
|
1
2
|
export * from './collections/index.mjs';
|
|
2
3
|
export * from './expect-type.mjs';
|
|
4
|
+
export * from './functional/index.mjs';
|
|
3
5
|
export * from './guard/index.mjs';
|
|
4
6
|
export * from './iterator/index.mjs';
|
|
5
7
|
export * from './json/index.mjs';
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-data-forge",
|
|
3
|
-
"version": "14.7.
|
|
3
|
+
"version": "14.7.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@sindresorhus/is": "^8.1.0",
|
|
40
|
-
"ts-std-forge": "^0.5.
|
|
40
|
+
"ts-std-forge": "^0.5.1",
|
|
41
41
|
"ts-type-forge": "~9.2.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@emotion/react": "11.14.0",
|
|
45
45
|
"@emotion/styled": "11.14.1",
|
|
46
46
|
"@mui/material": "9.4.0",
|
|
47
|
-
"@types/react": "19.
|
|
48
|
-
"@vitest/browser-playwright": "
|
|
49
|
-
"eslint-config-typed": "5.11.
|
|
47
|
+
"@types/react": "19.3.0",
|
|
48
|
+
"@vitest/browser-playwright": "5.0.0",
|
|
49
|
+
"eslint-config-typed": "5.11.7",
|
|
50
50
|
"eslint-plugin-ts-fortress": "1.2.2",
|
|
51
51
|
"eslint-plugin-ts-type-forge": "0.8.3",
|
|
52
52
|
"immer": "11.1.18",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
56
56
|
"prettier-plugin-packagejson": "3.0.2",
|
|
57
57
|
"react": "19.2.8",
|
|
58
|
-
"ts-repo-utils": "10.6.
|
|
58
|
+
"ts-repo-utils": "10.6.2",
|
|
59
59
|
"typedoc": "0.28.20",
|
|
60
60
|
"typedoc-github-theme": "0.4.0",
|
|
61
61
|
"vite": "8.2.2"
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"fmt:full": "pnpm run z:prettier .",
|
|
86
86
|
"gen:branded-number": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/gen-branded-number/generate.mts && pnpm run doc:embed:jsdoc && pnpm run z:prettier 'src/number/branded-types/*.mts' 'src/number/enum/*.mts'",
|
|
87
87
|
"gi": "run-s gi:src fmt",
|
|
88
|
-
"gi:src": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json
|
|
88
|
+
"gi:src": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/gen-index-ts.mts ./src --index-ext .mts --export-ext .mjs --target-ext .mts --exclude entry-point.mts --preserve 'array/index.mts' --preserve 'functional/index.mts'",
|
|
89
89
|
"lint": "eslint .",
|
|
90
90
|
"lint:fix": "eslint . --fix",
|
|
91
91
|
"test": "pnpm run z:vitest:node run",
|
|
@@ -33,13 +33,21 @@ import {
|
|
|
33
33
|
* const rgb = Arr.asFixedLengthArray(3, [255, 128, 0]);
|
|
34
34
|
*
|
|
35
35
|
* const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)
|
|
36
|
+
*
|
|
36
37
|
* const red: number = rgb[0]; // OK — no `undefined`
|
|
37
38
|
*
|
|
38
39
|
* // curried version
|
|
39
40
|
* const asRgb = Arr.asFixedLengthArray(3);
|
|
41
|
+
*
|
|
40
42
|
* const green = asRgb([0, 255, 0]);
|
|
41
43
|
*
|
|
42
|
-
*
|
|
44
|
+
* assert.deepStrictEqual(Array.from(atMost5), [255, 128, 0]);
|
|
45
|
+
*
|
|
46
|
+
* assert.strictEqual(red, 255);
|
|
47
|
+
*
|
|
48
|
+
* assert.deepStrictEqual(green, [0, 255, 0]);
|
|
49
|
+
*
|
|
50
|
+
* assert.throws(() => Arr.asFixedLengthArray(3, [255, 128]), TypeError);
|
|
43
51
|
* ```
|
|
44
52
|
*
|
|
45
53
|
* @template Length - The exact number of elements.
|
|
@@ -110,13 +118,21 @@ const asFixedLengthArrayImpl = <E,>(
|
|
|
110
118
|
* const history = Arr.asMinLengthArray(3, [0, 1, 2, 3]);
|
|
111
119
|
*
|
|
112
120
|
* const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)
|
|
121
|
+
*
|
|
113
122
|
* const first: number = history[0]; // OK — no `undefined`
|
|
114
123
|
*
|
|
115
124
|
* // curried version
|
|
116
125
|
* const asHistory = Arr.asMinLengthArray(3);
|
|
126
|
+
*
|
|
117
127
|
* const next = asHistory([4, 5, 6, 7]);
|
|
118
128
|
*
|
|
119
|
-
*
|
|
129
|
+
* assert.deepStrictEqual(Array.from(nonEmpty), [0, 1, 2, 3]);
|
|
130
|
+
*
|
|
131
|
+
* assert.strictEqual(first, 0);
|
|
132
|
+
*
|
|
133
|
+
* assert.deepStrictEqual(next, [4, 5, 6, 7]);
|
|
134
|
+
*
|
|
135
|
+
* assert.throws(() => Arr.asMinLengthArray(3, [0]), TypeError);
|
|
120
136
|
* ```
|
|
121
137
|
*
|
|
122
138
|
* @template MinLength - The minimum number of elements (inclusive).
|
|
@@ -188,9 +204,14 @@ const asMinLengthArrayImpl = <E,>(
|
|
|
188
204
|
*
|
|
189
205
|
* // curried version
|
|
190
206
|
* const asTags = Arr.asMaxLengthArray(8);
|
|
207
|
+
*
|
|
191
208
|
* const more = asTags(['d', 'e']);
|
|
192
209
|
*
|
|
193
|
-
*
|
|
210
|
+
* assert.deepStrictEqual(Array.from(relaxed), ['a', 'b', 'c']);
|
|
211
|
+
*
|
|
212
|
+
* assert.deepStrictEqual(more, ['d', 'e']);
|
|
213
|
+
*
|
|
214
|
+
* assert.throws(() => Arr.asMaxLengthArray(2, ['a', 'b', 'c']), TypeError);
|
|
194
215
|
* ```
|
|
195
216
|
*
|
|
196
217
|
* @template MaxLength - The maximum number of elements (inclusive).
|
|
@@ -264,9 +285,14 @@ const asMaxLengthArrayImpl = <E,>(
|
|
|
264
285
|
*
|
|
265
286
|
* // curried version
|
|
266
287
|
* const asSelection = Arr.asBoundedLengthArray(1, 5);
|
|
288
|
+
*
|
|
267
289
|
* const next = asSelection([4, 5]);
|
|
268
290
|
*
|
|
269
|
-
*
|
|
291
|
+
* assert.deepStrictEqual(Array.from(relaxed), [1, 2, 3]);
|
|
292
|
+
*
|
|
293
|
+
* assert.deepStrictEqual(next, [4, 5]);
|
|
294
|
+
*
|
|
295
|
+
* assert.throws(() => Arr.asBoundedLengthArray(1, 5, []), TypeError);
|
|
270
296
|
* ```
|
|
271
297
|
*
|
|
272
298
|
* @template MinLength - The minimum number of elements (inclusive).
|
|
@@ -349,7 +375,9 @@ const asBoundedLengthArrayImpl = <E,>(
|
|
|
349
375
|
*
|
|
350
376
|
* const atMost5: MaxLengthArray<5, never> = nothing; // OK (0 <= 5)
|
|
351
377
|
*
|
|
352
|
-
*
|
|
378
|
+
* assert.deepStrictEqual(Array.from(atMost5), []);
|
|
379
|
+
*
|
|
380
|
+
* assert.throws(() => Arr.asEmptyArray([1]), TypeError);
|
|
353
381
|
* ```
|
|
354
382
|
*
|
|
355
383
|
* @template Xs - The input array type (tuple types are preserved).
|
|
@@ -387,7 +415,9 @@ export const asEmptyArray = <Xs extends readonly unknown[]>(
|
|
|
387
415
|
*
|
|
388
416
|
* const first: number = history[0]; // OK — no `undefined`
|
|
389
417
|
*
|
|
390
|
-
*
|
|
418
|
+
* assert.strictEqual(first, 0);
|
|
419
|
+
*
|
|
420
|
+
* assert.throws(() => Arr.asNonEmptyArray([]), TypeError);
|
|
391
421
|
* ```
|
|
392
422
|
*
|
|
393
423
|
* @template Xs - The input array type (tuple types are preserved).
|
|
@@ -36,7 +36,11 @@ import {
|
|
|
36
36
|
* // curried version
|
|
37
37
|
* const asRgb = Arr.asFixedLengthTuple(3);
|
|
38
38
|
*
|
|
39
|
-
*
|
|
39
|
+
* assert.strictEqual(red, 255);
|
|
40
|
+
*
|
|
41
|
+
* assert.deepStrictEqual(asRgb([0, 255, 0]), [0, 255, 0]);
|
|
42
|
+
*
|
|
43
|
+
* assert.throws(() => Arr.asFixedLengthTuple(3, [255, 128]), TypeError);
|
|
40
44
|
* ```
|
|
41
45
|
*
|
|
42
46
|
* @template Length - The exact number of elements.
|
|
@@ -104,7 +108,11 @@ const asFixedLengthTupleImpl = (
|
|
|
104
108
|
* // curried version
|
|
105
109
|
* const asHistory = Arr.asMinLengthTuple(3);
|
|
106
110
|
*
|
|
107
|
-
*
|
|
111
|
+
* assert.strictEqual(first, 0);
|
|
112
|
+
*
|
|
113
|
+
* assert.deepStrictEqual(asHistory([4, 5, 6]), [4, 5, 6]);
|
|
114
|
+
*
|
|
115
|
+
* assert.throws(() => Arr.asMinLengthTuple(3, [0, 1]), TypeError);
|
|
108
116
|
* ```
|
|
109
117
|
*
|
|
110
118
|
* @template MinLength - The minimum number of elements (inclusive).
|
|
@@ -170,7 +178,11 @@ const asMinLengthTupleImpl = (
|
|
|
170
178
|
* // curried version
|
|
171
179
|
* const asTags = Arr.asMaxLengthTuple(8);
|
|
172
180
|
*
|
|
173
|
-
*
|
|
181
|
+
* assert.deepStrictEqual(tags, ['a', 'b', 'c']);
|
|
182
|
+
*
|
|
183
|
+
* assert.deepStrictEqual(asTags(['d', 'e']), ['d', 'e']);
|
|
184
|
+
*
|
|
185
|
+
* assert.throws(() => Arr.asMaxLengthTuple(2, ['a', 'b', 'c']), TypeError);
|
|
174
186
|
* ```
|
|
175
187
|
*
|
|
176
188
|
* @template MaxLength - The maximum number of elements (inclusive).
|
|
@@ -236,7 +248,11 @@ const asMaxLengthTupleImpl = (
|
|
|
236
248
|
* // curried version
|
|
237
249
|
* const asSelection = Arr.asBoundedLengthTuple(1, 5);
|
|
238
250
|
*
|
|
239
|
-
*
|
|
251
|
+
* assert.deepStrictEqual(selection, [1, 2, 3]);
|
|
252
|
+
*
|
|
253
|
+
* assert.deepStrictEqual(asSelection([4, 5]), [4, 5]);
|
|
254
|
+
*
|
|
255
|
+
* assert.throws(() => Arr.asBoundedLengthTuple(1, 2, [1, 2, 3]), TypeError);
|
|
240
256
|
* ```
|
|
241
257
|
*
|
|
242
258
|
* @template Min - The minimum number of elements (inclusive).
|
|
@@ -311,7 +327,9 @@ const asBoundedLengthTupleImpl = (
|
|
|
311
327
|
* ```ts
|
|
312
328
|
* const nothing = Arr.asEmptyTuple([]);
|
|
313
329
|
*
|
|
314
|
-
*
|
|
330
|
+
* assert.deepStrictEqual(nothing, []);
|
|
331
|
+
*
|
|
332
|
+
* assert.throws(() => Arr.asEmptyTuple([1]), TypeError);
|
|
315
333
|
* ```
|
|
316
334
|
*
|
|
317
335
|
* @template Xs - The input array type (tuple types are preserved).
|
|
@@ -345,7 +363,9 @@ export const asEmptyTuple = <Xs extends readonly unknown[]>(
|
|
|
345
363
|
*
|
|
346
364
|
* const first: number = values[0]; // OK — no `undefined`
|
|
347
365
|
*
|
|
348
|
-
*
|
|
366
|
+
* assert.strictEqual(first, 1);
|
|
367
|
+
*
|
|
368
|
+
* assert.throws(() => Arr.asNonEmptyTuple([]), TypeError);
|
|
349
369
|
* ```
|
|
350
370
|
*
|
|
351
371
|
* @template Xs - The input array type (tuple types are preserved).
|
package/src/index.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from './array/index.mjs';
|
|
1
2
|
export * from './collections/index.mjs';
|
|
2
3
|
export * from './expect-type.mjs';
|
|
4
|
+
export * from './functional/index.mjs';
|
|
3
5
|
export * from './guard/index.mjs';
|
|
4
6
|
export * from './iterator/index.mjs';
|
|
5
7
|
export * from './json/index.mjs';
|