@ddd-ts/shape 0.0.36 → 0.0.37
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/package.json +15 -6
- package/dist/_.d.ts +0 -39
- package/dist/_.d.ts.map +0 -1
- package/dist/_.js +0 -55
- package/dist/_.js.map +0 -1
- package/dist/addons/microsecond-timestamp.d.ts +0 -24
- package/dist/addons/microsecond-timestamp.d.ts.map +0 -1
- package/dist/addons/microsecond-timestamp.js +0 -75
- package/dist/addons/microsecond-timestamp.js.map +0 -1
- package/dist/choice.d.ts +0 -30
- package/dist/choice.d.ts.map +0 -1
- package/dist/choice.js +0 -49
- package/dist/choice.js.map +0 -1
- package/dist/choice.spec.d.ts +0 -2
- package/dist/choice.spec.d.ts.map +0 -1
- package/dist/choice.spec.js +0 -147
- package/dist/choice.spec.js.map +0 -1
- package/dist/class.d.ts +0 -23
- package/dist/class.d.ts.map +0 -1
- package/dist/class.js +0 -31
- package/dist/class.js.map +0 -1
- package/dist/class.spec.d.ts +0 -2
- package/dist/class.spec.d.ts.map +0 -1
- package/dist/class.spec.js +0 -39
- package/dist/class.spec.js.map +0 -1
- package/dist/dict.d.ts +0 -43
- package/dist/dict.d.ts.map +0 -1
- package/dist/dict.js +0 -47
- package/dist/dict.js.map +0 -1
- package/dist/dict.spec.d.ts +0 -2
- package/dist/dict.spec.d.ts.map +0 -1
- package/dist/dict.spec.js +0 -180
- package/dist/dict.spec.js.map +0 -1
- package/dist/discriminated-union.d.ts +0 -74
- package/dist/discriminated-union.d.ts.map +0 -1
- package/dist/discriminated-union.js +0 -97
- package/dist/discriminated-union.js.map +0 -1
- package/dist/discriminated-union.spec.d.ts +0 -2
- package/dist/discriminated-union.spec.d.ts.map +0 -1
- package/dist/discriminated-union.spec.js +0 -262
- package/dist/discriminated-union.spec.js.map +0 -1
- package/dist/either.d.ts +0 -84
- package/dist/either.d.ts.map +0 -1
- package/dist/either.js +0 -62
- package/dist/either.js.map +0 -1
- package/dist/either.spec.d.ts +0 -2
- package/dist/either.spec.d.ts.map +0 -1
- package/dist/either.spec.js +0 -232
- package/dist/either.spec.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -1
- package/dist/literal.d.ts +0 -15
- package/dist/literal.d.ts.map +0 -1
- package/dist/literal.js +0 -27
- package/dist/literal.js.map +0 -1
- package/dist/literal.spec.d.ts +0 -2
- package/dist/literal.spec.d.ts.map +0 -1
- package/dist/literal.spec.js +0 -162
- package/dist/literal.spec.js.map +0 -1
- package/dist/mapping.d.ts +0 -43
- package/dist/mapping.d.ts.map +0 -1
- package/dist/mapping.js +0 -50
- package/dist/mapping.js.map +0 -1
- package/dist/mapping.spec.d.ts +0 -2
- package/dist/mapping.spec.d.ts.map +0 -1
- package/dist/mapping.spec.js +0 -207
- package/dist/mapping.spec.js.map +0 -1
- package/dist/multiple.d.ts +0 -20
- package/dist/multiple.d.ts.map +0 -1
- package/dist/multiple.js +0 -120
- package/dist/multiple.js.map +0 -1
- package/dist/multiple.spec.d.ts +0 -2
- package/dist/multiple.spec.d.ts.map +0 -1
- package/dist/multiple.spec.js +0 -207
- package/dist/multiple.spec.js.map +0 -1
- package/dist/nothing.d.ts +0 -14
- package/dist/nothing.d.ts.map +0 -1
- package/dist/nothing.js +0 -19
- package/dist/nothing.js.map +0 -1
- package/dist/nothing.spec.d.ts +0 -2
- package/dist/nothing.spec.d.ts.map +0 -1
- package/dist/nothing.spec.js +0 -172
- package/dist/nothing.spec.js.map +0 -1
- package/dist/optional.d.ts +0 -26
- package/dist/optional.d.ts.map +0 -1
- package/dist/optional.js +0 -41
- package/dist/optional.js.map +0 -1
- package/dist/optional.spec.d.ts +0 -2
- package/dist/optional.spec.d.ts.map +0 -1
- package/dist/optional.spec.js +0 -172
- package/dist/optional.spec.js.map +0 -1
- package/dist/primitive.d.ts +0 -38
- package/dist/primitive.d.ts.map +0 -1
- package/dist/primitive.js +0 -33
- package/dist/primitive.js.map +0 -1
- package/dist/primitive.spec.d.ts +0 -2
- package/dist/primitive.spec.d.ts.map +0 -1
- package/dist/primitive.spec.js +0 -162
- package/dist/primitive.spec.js.map +0 -1
- package/dist/test.d.ts +0 -36
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -45
- package/dist/test.js.map +0 -1
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const dict_1 = require("./dict");
|
|
4
|
-
const test_1 = require("./test");
|
|
5
|
-
const discriminated_union_1 = require("./discriminated-union");
|
|
6
|
-
describe("DiscriminatedUnion", () => {
|
|
7
|
-
it("class definition with two arguments", () => {
|
|
8
|
-
class A extends (0, dict_1.Dict)({ type: "A", a: String }) {
|
|
9
|
-
}
|
|
10
|
-
const B = (0, dict_1.Dict)({ type: "B", b: Number });
|
|
11
|
-
const C = { type: "C", c: Boolean };
|
|
12
|
-
class Test extends (0, discriminated_union_1.DiscriminatedUnion)([A, B, C]) {
|
|
13
|
-
test = true;
|
|
14
|
-
}
|
|
15
|
-
// Constructor parameters
|
|
16
|
-
(0, test_1.ex)(Test).toHaveFirstParam().ok;
|
|
17
|
-
// Deserialization
|
|
18
|
-
(0, test_1.ex)(Test.deserialize).toHaveFirstParam().ok;
|
|
19
|
-
const a = Test.deserialize({ type: "A", a: "test" });
|
|
20
|
-
(0, test_1.ex)(a).toBeInstanceOf(Test).ok;
|
|
21
|
-
// Additional prototype
|
|
22
|
-
(0, test_1.ex)(a.test).toBe(true).ok;
|
|
23
|
-
// Inherited prototype on deserialization
|
|
24
|
-
(0, test_1.ex)(a.value).toStrictEqual(new A({ type: "A", a: "test" })).ok;
|
|
25
|
-
// Serialization
|
|
26
|
-
(0, test_1.ex)(a.serialize()).toStrictEqual({
|
|
27
|
-
type: "A",
|
|
28
|
-
a: "test",
|
|
29
|
-
}).ok;
|
|
30
|
-
// Instantiation
|
|
31
|
-
const b = new Test(new A({ type: "A", a: "test" }));
|
|
32
|
-
(0, test_1.ex)(b).toBeInstanceOf(Test).ok;
|
|
33
|
-
// Inherited prototype on instantiation
|
|
34
|
-
(0, test_1.ex)(b.value).toStrictEqual(new A({ type: "A", a: "test" })).ok;
|
|
35
|
-
const c = new Test({ type: "B", b: 2 });
|
|
36
|
-
(0, test_1.ex)(c).toBeInstanceOf(Test).ok;
|
|
37
|
-
(0, test_1.ex)(c.value).toStrictEqual({ type: "B", b: 2 }).ok;
|
|
38
|
-
(0, test_1.ex)(c.serialize()).toStrictEqual({ type: "B", b: 2 }).ok;
|
|
39
|
-
const c2 = Test.deserialize({ type: "B", b: 2 });
|
|
40
|
-
(0, test_1.ex)(c2).toBeInstanceOf(Test).ok;
|
|
41
|
-
(0, test_1.ex)(c2.value).toStrictEqual({ type: "B", b: 2 }).ok;
|
|
42
|
-
(0, test_1.ex)(c2.serialize()).toStrictEqual({ type: "B", b: 2 }).ok;
|
|
43
|
-
const d = new Test({ type: "C", c: true });
|
|
44
|
-
(0, test_1.ex)(d).toBeInstanceOf(Test).ok;
|
|
45
|
-
(0, test_1.ex)(d.value).toStrictEqual({ type: "C", c: true }).ok;
|
|
46
|
-
(0, test_1.ex)(d.serialize()).toStrictEqual({ type: "C", c: true }).ok;
|
|
47
|
-
const d2 = Test.deserialize({ type: "C", c: true });
|
|
48
|
-
(0, test_1.ex)(d2).toBeInstanceOf(Test).ok;
|
|
49
|
-
(0, test_1.ex)(d2.value).toStrictEqual({ type: "C", c: true }).ok;
|
|
50
|
-
(0, test_1.ex)(d2.serialize()).toStrictEqual({ type: "C", c: true }).ok;
|
|
51
|
-
});
|
|
52
|
-
it("class definition with constructors", () => {
|
|
53
|
-
class A extends (0, dict_1.Dict)({ type: "A", a: String }) {
|
|
54
|
-
}
|
|
55
|
-
class B {
|
|
56
|
-
static type = "B";
|
|
57
|
-
type;
|
|
58
|
-
a;
|
|
59
|
-
constructor({ type, a }) {
|
|
60
|
-
Object.assign(this, { type, a });
|
|
61
|
-
}
|
|
62
|
-
static deserialize({ type, a }) {
|
|
63
|
-
return new B({ type, a });
|
|
64
|
-
}
|
|
65
|
-
serialize() {
|
|
66
|
-
return { type: this.type, a: this.a };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
class Test extends (0, discriminated_union_1.DiscriminatedUnion)([A, B]) {
|
|
70
|
-
test = true;
|
|
71
|
-
}
|
|
72
|
-
// Constructor parameters
|
|
73
|
-
(0, test_1.ex)(Test).toHaveFirstParam().ok;
|
|
74
|
-
// Deserialization
|
|
75
|
-
(0, test_1.ex)(Test.deserialize).toHaveFirstParam().ok;
|
|
76
|
-
const a = Test.deserialize({ type: "A", a: "a" });
|
|
77
|
-
(0, test_1.ex)(a).toBeInstanceOf(Test).ok;
|
|
78
|
-
const b = Test.deserialize({ type: "B", a: "b" });
|
|
79
|
-
(0, test_1.ex)(b).toBeInstanceOf(Test).ok;
|
|
80
|
-
// Additional prototype
|
|
81
|
-
(0, test_1.ex)(a.match({
|
|
82
|
-
A: () => true,
|
|
83
|
-
B: () => false,
|
|
84
|
-
})).toBe(true).ok;
|
|
85
|
-
(0, test_1.ex)(a.match({
|
|
86
|
-
_: () => true,
|
|
87
|
-
})).toBe(true).ok;
|
|
88
|
-
(0, test_1.ex)(a.match({
|
|
89
|
-
B: () => true,
|
|
90
|
-
}, () => false)).toBe(false).ok;
|
|
91
|
-
(0, test_1.ex)(a.test).toBe(true).ok;
|
|
92
|
-
// Inherited prototype on deserialization
|
|
93
|
-
(0, test_1.ex)(a.value).toBeInstanceOf(A).ok;
|
|
94
|
-
(0, test_1.ex)(b.value).toBeInstanceOf(B).ok;
|
|
95
|
-
// Serialization
|
|
96
|
-
(0, test_1.ex)(a.serialize()).toStrictEqual({ type: "A", a: "a" }).ok;
|
|
97
|
-
(0, test_1.ex)(b.serialize()).toStrictEqual({ type: "B", a: "b" }).ok;
|
|
98
|
-
// Instantiation
|
|
99
|
-
const c = new Test(new A({ type: "A", a: "aa" }));
|
|
100
|
-
(0, test_1.ex)(c).toBeInstanceOf(Test).ok;
|
|
101
|
-
const d = new Test(new B({ type: "B", a: "bb" }));
|
|
102
|
-
(0, test_1.ex)(d).toBeInstanceOf(Test).ok;
|
|
103
|
-
// Inherited prototype
|
|
104
|
-
(0, test_1.ex)(c.value).toBeInstanceOf(A).ok;
|
|
105
|
-
(0, test_1.ex)(c.value.a).toBe("aa").ok;
|
|
106
|
-
(0, test_1.ex)(d.value).toBeInstanceOf(B).ok;
|
|
107
|
-
(0, test_1.ex)(d.value.a).toBe("bb").ok;
|
|
108
|
-
});
|
|
109
|
-
it("inline definition", () => {
|
|
110
|
-
class A extends (0, dict_1.Dict)({ type: "A", a: String }) {
|
|
111
|
-
}
|
|
112
|
-
const B = (0, dict_1.Dict)({ type: "B", b: Number });
|
|
113
|
-
class Test extends (0, dict_1.Dict)({ nested: (0, discriminated_union_1.DiscriminatedUnion)([A, B]) }) {
|
|
114
|
-
}
|
|
115
|
-
// Constructor parameters
|
|
116
|
-
(0, test_1.ex)(Test).toHaveFirstParam().ok;
|
|
117
|
-
// Deserialization
|
|
118
|
-
(0, test_1.ex)(Test.deserialize).toHaveFirstParam().ok;
|
|
119
|
-
const a = Test.deserialize({ nested: { type: "A", a: "test" } });
|
|
120
|
-
(0, test_1.ex)(a).toBeInstanceOf(Test).ok;
|
|
121
|
-
// Inherited prototype on deserialization
|
|
122
|
-
(0, test_1.ex)(a.nested).toStrictEqual(new A({ type: "A", a: "test" })).ok;
|
|
123
|
-
// Serialization
|
|
124
|
-
(0, test_1.ex)(a.serialize()).toStrictEqual({
|
|
125
|
-
nested: { type: "A", a: "test" },
|
|
126
|
-
}).ok;
|
|
127
|
-
// Instantiation
|
|
128
|
-
const b = new Test({ nested: { type: "B", b: 0 } });
|
|
129
|
-
(0, test_1.ex)(b).toBeInstanceOf(Test).ok;
|
|
130
|
-
// Inherited prototype on instantiation
|
|
131
|
-
(0, test_1.ex)(b.nested).toStrictEqual({ type: "B", b: 0 }).ok;
|
|
132
|
-
});
|
|
133
|
-
it("referenced definition", () => {
|
|
134
|
-
class A extends (0, dict_1.Dict)({ type: "A" }) {
|
|
135
|
-
}
|
|
136
|
-
class B extends (0, dict_1.Dict)({ type: "B" }) {
|
|
137
|
-
}
|
|
138
|
-
class Union extends (0, discriminated_union_1.DiscriminatedUnion)([A, B]) {
|
|
139
|
-
}
|
|
140
|
-
class Test extends (0, dict_1.Dict)({ nested: Union }) {
|
|
141
|
-
}
|
|
142
|
-
// Constructor parameters
|
|
143
|
-
(0, test_1.ex)(Test).toHaveFirstParam().ok;
|
|
144
|
-
// Deserialization
|
|
145
|
-
(0, test_1.ex)(Test.deserialize).toHaveFirstParam().ok;
|
|
146
|
-
const a = Test.deserialize({ nested: { type: "A" } });
|
|
147
|
-
(0, test_1.ex)(a).toBeInstanceOf(Test).ok;
|
|
148
|
-
// Inherited prototype on deserialization
|
|
149
|
-
(0, test_1.ex)(a.nested).toBeInstanceOf(Union).ok;
|
|
150
|
-
(0, test_1.ex)(a.nested.value).toStrictEqual(new A({ type: "A" })).ok;
|
|
151
|
-
// Serialization
|
|
152
|
-
(0, test_1.ex)(a.serialize()).toStrictEqual({ nested: { type: "A" } }).ok;
|
|
153
|
-
// Instantiation
|
|
154
|
-
const b = new Test({ nested: new Union(new A({ type: "A" })) });
|
|
155
|
-
(0, test_1.ex)(b).toBeInstanceOf(Test).ok;
|
|
156
|
-
// Inherited prototype on instantiation
|
|
157
|
-
(0, test_1.ex)(b.nested.value).toStrictEqual(new A({ type: "A" })).ok;
|
|
158
|
-
});
|
|
159
|
-
it("mixin extension", () => {
|
|
160
|
-
const Mixin = (config) => {
|
|
161
|
-
class Mix extends (0, discriminated_union_1.DiscriminatedUnion)(config) {
|
|
162
|
-
deep = true;
|
|
163
|
-
static deep = true;
|
|
164
|
-
}
|
|
165
|
-
return Mix;
|
|
166
|
-
};
|
|
167
|
-
class A extends (0, dict_1.Dict)({ type: "A" }) {
|
|
168
|
-
}
|
|
169
|
-
class B extends (0, dict_1.Dict)({ type: "B" }) {
|
|
170
|
-
}
|
|
171
|
-
class Test extends Mixin([A, B]) {
|
|
172
|
-
test = true;
|
|
173
|
-
// @ts-expect-error is not assignable to parameter of type 'true'
|
|
174
|
-
abstract = false;
|
|
175
|
-
}
|
|
176
|
-
// Constructor parameters
|
|
177
|
-
(0, test_1.ex)(Test).toHaveFirstParam().ok;
|
|
178
|
-
// Additional static prototype
|
|
179
|
-
(0, test_1.ex)(Test.deep).toBe(true).ok;
|
|
180
|
-
// Deserialization
|
|
181
|
-
(0, test_1.ex)(Test.deserialize).toHaveFirstParam().ok;
|
|
182
|
-
const a = Test.deserialize({ type: "A" });
|
|
183
|
-
(0, test_1.ex)(a).toBeInstanceOf(Test).ok;
|
|
184
|
-
// Additional prototype on deserialization
|
|
185
|
-
(0, test_1.ex)(a.test).toBe(true).ok;
|
|
186
|
-
(0, test_1.ex)(a.abstract).toBe(false).ok;
|
|
187
|
-
// Extended prototype on deserialization
|
|
188
|
-
(0, test_1.ex)(a.deep).toBe(true).ok;
|
|
189
|
-
// Inherited prototype on deserialization
|
|
190
|
-
(0, test_1.ex)(a.value).toStrictEqual(new A({ type: "A" })).ok;
|
|
191
|
-
// Serialization
|
|
192
|
-
(0, test_1.ex)(a.serialize()).toStrictEqual({ type: "A" }).ok;
|
|
193
|
-
// Instantiation
|
|
194
|
-
const b = new Test(new B({ type: "B" }));
|
|
195
|
-
(0, test_1.ex)(b).toBeInstanceOf(Test).ok;
|
|
196
|
-
// Additional prototype on instantiation
|
|
197
|
-
(0, test_1.ex)(b.test).toBe(true).ok;
|
|
198
|
-
(0, test_1.ex)(b.abstract).toBe(false).ok;
|
|
199
|
-
// Extended prototype on instantiation
|
|
200
|
-
(0, test_1.ex)(b.deep).toBe(true).ok;
|
|
201
|
-
// Inherited prototype on instantiation
|
|
202
|
-
(0, test_1.ex)(b.value).toStrictEqual(new B({ type: "B" })).ok;
|
|
203
|
-
});
|
|
204
|
-
it("mixin supersede", () => {
|
|
205
|
-
const Testable = (config) => {
|
|
206
|
-
class I {
|
|
207
|
-
deep = true;
|
|
208
|
-
static deep = true;
|
|
209
|
-
}
|
|
210
|
-
return (0, discriminated_union_1.DiscriminatedUnion)(config, I);
|
|
211
|
-
};
|
|
212
|
-
class A extends (0, dict_1.Dict)({ type: "A" }) {
|
|
213
|
-
}
|
|
214
|
-
class B extends (0, dict_1.Dict)({ type: "B" }) {
|
|
215
|
-
}
|
|
216
|
-
class Test extends Testable([A, B]) {
|
|
217
|
-
test = true;
|
|
218
|
-
// @ts-expect-error is not assignable to parameter of type 'true'
|
|
219
|
-
abstract = false;
|
|
220
|
-
}
|
|
221
|
-
// Constructor type
|
|
222
|
-
(0, test_1.ex)(Test).toHaveFirstParam().ok;
|
|
223
|
-
// Additional static prototype
|
|
224
|
-
(0, test_1.ex)(Test.deep).toBe(true).ok;
|
|
225
|
-
// Deserialization
|
|
226
|
-
(0, test_1.ex)(Test.deserialize).toHaveFirstParam().ok;
|
|
227
|
-
const a = Test.deserialize({ type: "A" });
|
|
228
|
-
(0, test_1.ex)(a).toBeInstanceOf(Test).ok;
|
|
229
|
-
// Additional prototype on deserialization
|
|
230
|
-
(0, test_1.ex)(a.test).toBe(true).ok;
|
|
231
|
-
(0, test_1.ex)(a.abstract).toBe(false).ok;
|
|
232
|
-
// Superseded prototype on deserialization
|
|
233
|
-
(0, test_1.ex)(a.deep).toBe(true).ok;
|
|
234
|
-
// Inherited prototype on deserialization
|
|
235
|
-
(0, test_1.ex)(a.value).toStrictEqual(new A({ type: "A" })).ok;
|
|
236
|
-
// Serialization
|
|
237
|
-
(0, test_1.ex)(a.serialize()).toStrictEqual({
|
|
238
|
-
type: "A",
|
|
239
|
-
}).ok;
|
|
240
|
-
// Instantiation
|
|
241
|
-
const b = new Test(new B({ type: "B" }));
|
|
242
|
-
(0, test_1.ex)(b).toBeInstanceOf(Test).ok;
|
|
243
|
-
// Additional prototype on instantiation
|
|
244
|
-
(0, test_1.ex)(b.test).toBe(true).ok;
|
|
245
|
-
(0, test_1.ex)(b.abstract).toBe(false).ok;
|
|
246
|
-
// Superseded prototype on instantiation
|
|
247
|
-
(0, test_1.ex)(b.deep).toBe(true).ok;
|
|
248
|
-
(0, test_1.ex)(b.abstract).toBe(false).ok;
|
|
249
|
-
// Inherited prototype on instantiation
|
|
250
|
-
(0, test_1.ex)(b.value).toStrictEqual(new B({ type: "B" })).ok;
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
// making the config `as const` breaks the freeze command
|
|
254
|
-
// This enforces the use of `as const` in the discriminator
|
|
255
|
-
// This is ugly
|
|
256
|
-
class A extends (0, discriminated_union_1.DiscriminatedUnion)([
|
|
257
|
-
{ type: "A" },
|
|
258
|
-
{ type: "B" },
|
|
259
|
-
]) {
|
|
260
|
-
}
|
|
261
|
-
const _shouldBeFreezable = true;
|
|
262
|
-
//# sourceMappingURL=discriminated-union.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discriminated-union.spec.js","sourceRoot":"","sources":["../src/discriminated-union.spec.ts"],"names":[],"mappings":";;AAAA,iCAA8B;AAC9B,iCAAyC;AACzC,+DAG+B;AAE/B,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAE,SAAQ,IAAA,WAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;SAAG;QACjD,MAAM,CAAC,GAAG,IAAA,WAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,GAAY,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;QAE7C,MAAM,IAAK,SAAQ,IAAA,wCAAkB,EAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YA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AAC,CAAC,CAAC,KAAK,CAAC,CAAC,aAAa,CAAQ,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,yDAAyD;AACzD,2DAA2D;AAC3D,eAAe;AACf,MAAM,CAAE,SAAQ,IAAA,wCAAkB,EAAC;IACjC,EAAE,IAAI,EAAE,GAAY,EAAE;IACtB,EAAE,IAAI,EAAE,GAAY,EAAE;CACvB,CAAC;CAAG;AACL,MAAM,kBAAkB,GAGpB,IAAI,CAAC","sourcesContent":["import { Dict } from \"./dict\";\nimport { ex, type Equals } from \"./test\";\nimport {\n DiscriminatedUnion,\n DiscriminatedUnionConfiguration,\n} from \"./discriminated-union\";\n\ndescribe(\"DiscriminatedUnion\", () => {\n it(\"class definition with two arguments\", () => {\n class A extends Dict({ type: \"A\", a: String }) {}\n const B = Dict({ type: \"B\", b: Number });\n const C = { type: \"C\" as const, c: Boolean };\n\n class Test extends DiscriminatedUnion([A, B, C]) {\n test = true as const;\n }\n\n type Inlined = A | { type: \"B\"; b: number } | { type: \"C\"; c: boolean };\n type Serialized =\n | { type: \"A\"; a: string }\n | { type: \"B\"; b: number }\n | { type: \"C\"; c: boolean };\n\n // Constructor parameters\n ex(Test).toHaveFirstParam<Inlined>().ok;\n\n // Deserialization\n ex(Test.deserialize).toHaveFirstParam<Serialized>().ok;\n const a = Test.deserialize({ type: \"A\", a: \"test\" });\n ex(a).toBeInstanceOf(Test).ok;\n\n // Additional prototype\n ex(a.test).toBe(true as const).ok;\n\n // Inherited prototype on deserialization\n ex(a.value).toStrictEqual<Inlined>(new A({ type: \"A\", a: \"test\" })).ok;\n\n // Serialization\n ex(a.serialize()).toStrictEqual<Serialized>({\n type: \"A\",\n a: \"test\",\n }).ok;\n\n // Instantiation\n const b = new Test(new A({ type: \"A\", a: \"test\" }));\n ex(b).toBeInstanceOf(Test).ok;\n\n // Inherited prototype on instantiation\n ex(b.value).toStrictEqual<Inlined>(new A({ type: \"A\", a: \"test\" })).ok;\n\n const c = new Test({ type: \"B\", b: 2 });\n ex(c).toBeInstanceOf(Test).ok;\n ex(c.value).toStrictEqual<Inlined>({ type: \"B\", b: 2 }).ok;\n ex(c.serialize()).toStrictEqual<Serialized>({ type: \"B\", b: 2 }).ok;\n\n const c2 = Test.deserialize({ type: \"B\", b: 2 });\n ex(c2).toBeInstanceOf(Test).ok;\n ex(c2.value).toStrictEqual<Inlined>({ type: \"B\", b: 2 }).ok;\n ex(c2.serialize()).toStrictEqual<Serialized>({ type: \"B\", b: 2 }).ok;\n\n const d = new Test({ type: \"C\", c: true });\n ex(d).toBeInstanceOf(Test).ok;\n ex(d.value).toStrictEqual<Inlined>({ type: \"C\", c: true }).ok;\n ex(d.serialize()).toStrictEqual<Serialized>({ type: \"C\", c: true }).ok;\n\n const d2 = Test.deserialize({ type: \"C\", c: true });\n ex(d2).toBeInstanceOf(Test).ok;\n ex(d2.value).toStrictEqual<Inlined>({ type: \"C\", c: true }).ok;\n ex(d2.serialize()).toStrictEqual<Serialized>({ type: \"C\", c: true }).ok;\n });\n\n it(\"class definition with constructors\", () => {\n class A extends Dict({ type: \"A\", a: String }) {}\n class B {\n static type = \"B\" as const;\n type!: \"B\";\n a!: string;\n constructor({ type, a }: { type: \"B\"; a: string }) {\n Object.assign(this, { type, a });\n }\n\n static deserialize({ type, a }: { type: \"B\"; a: string }) {\n return new B({ type, a });\n }\n\n serialize() {\n return { type: this.type, a: this.a };\n }\n }\n\n class Test extends DiscriminatedUnion([A, B]) {\n test = true as const;\n }\n\n type Serialized = { type: \"A\"; a: string } | { type: \"B\"; a: string };\n\n // Constructor parameters\n ex(Test).toHaveFirstParam<A | B>().ok;\n\n // Deserialization\n ex(Test.deserialize).toHaveFirstParam<Serialized>().ok;\n const a = Test.deserialize({ type: \"A\", a: \"a\" });\n ex(a).toBeInstanceOf(Test).ok;\n const b = Test.deserialize({ type: \"B\", a: \"b\" });\n ex(b).toBeInstanceOf(Test).ok;\n\n // Additional prototype\n ex(\n a.match({\n A: () => true as const,\n B: () => false as const,\n }),\n ).toBe<true | false>(true as const).ok;\n ex(\n a.match({\n _: () => true as const,\n }),\n ).toBe<true>(true as const).ok;\n ex(\n a.match(\n {\n B: () => true as const,\n },\n () => false as const,\n ),\n ).toBe<true | false>(false as const).ok;\n\n ex(a.test).toBe(true as const).ok;\n // Inherited prototype on deserialization\n ex(a.value).toBeInstanceOf<typeof A | typeof B>(A).ok;\n ex(b.value).toBeInstanceOf<typeof A | typeof B>(B).ok;\n\n // Serialization\n ex(a.serialize()).toStrictEqual<Serialized>({ type: \"A\", a: \"a\" }).ok;\n ex(b.serialize()).toStrictEqual<Serialized>({ type: \"B\", a: \"b\" }).ok;\n\n // Instantiation\n const c = new Test(new A({ type: \"A\", a: \"aa\" }));\n ex(c).toBeInstanceOf(Test).ok;\n\n const d = new Test(new B({ type: \"B\", a: \"bb\" }));\n ex(d).toBeInstanceOf(Test).ok;\n\n // Inherited prototype\n ex(c.value).toBeInstanceOf<typeof A | typeof B>(A).ok;\n ex(c.value.a).toBe(\"aa\").ok;\n\n ex(d.value).toBeInstanceOf<typeof A | typeof B>(B).ok;\n ex(d.value.a).toBe(\"bb\").ok;\n });\n\n it(\"inline definition\", () => {\n class A extends Dict({ type: \"A\", a: String }) {}\n const B = Dict({ type: \"B\", b: Number });\n\n class Test extends Dict({ nested: DiscriminatedUnion([A, B]) }) {}\n\n type Inlined = { nested: A | { type: \"B\"; b: number } };\n type Serialized = {\n nested: { type: \"A\"; a: string } | { type: \"B\"; b: number };\n };\n\n // Constructor parameters\n ex(Test).toHaveFirstParam<Inlined>().ok;\n\n // Deserialization\n ex(Test.deserialize).toHaveFirstParam<Serialized>().ok;\n const a: Test = Test.deserialize({ nested: { type: \"A\", a: \"test\" } });\n ex(a).toBeInstanceOf(Test).ok;\n\n // Inherited prototype on deserialization\n ex(a.nested).toStrictEqual<Inlined[\"nested\"]>(\n new A({ type: \"A\", a: \"test\" }),\n ).ok;\n\n // Serialization\n ex(a.serialize()).toStrictEqual<Serialized>({\n nested: { type: \"A\", a: \"test\" },\n }).ok;\n\n // Instantiation\n const b = new Test({ nested: { type: \"B\", b: 0 } });\n ex(b).toBeInstanceOf(Test).ok;\n\n // Inherited prototype on instantiation\n ex(b.nested).toStrictEqual<Inlined[\"nested\"]>({ type: \"B\", b: 0 }).ok;\n });\n\n it(\"referenced definition\", () => {\n class A extends Dict({ type: \"A\" }) {}\n class B extends Dict({ type: \"B\" }) {}\n\n class Union extends DiscriminatedUnion([A, B]) {}\n class Test extends Dict({ nested: Union }) {}\n\n type Serialized = { nested: { type: \"A\" } | { type: \"B\" } };\n\n // Constructor parameters\n ex(Test).toHaveFirstParam<{ nested: Union }>().ok;\n\n // Deserialization\n ex(Test.deserialize).toHaveFirstParam<Serialized>().ok;\n const a: Test = Test.deserialize({ nested: { type: \"A\" } });\n ex(a).toBeInstanceOf(Test).ok;\n\n // Inherited prototype on deserialization\n ex(a.nested).toBeInstanceOf(Union).ok;\n ex(a.nested.value).toStrictEqual<Union[\"value\"]>(new A({ type: \"A\" })).ok;\n\n // Serialization\n ex(a.serialize()).toStrictEqual<Serialized>({ nested: { type: \"A\" } }).ok;\n\n // Instantiation\n const b: Test = new Test({ nested: new Union(new A({ type: \"A\" })) });\n ex(b).toBeInstanceOf(Test).ok;\n\n // Inherited prototype on instantiation\n ex(b.nested.value).toStrictEqual<A | B>(new A({ type: \"A\" })).ok;\n });\n\n it(\"mixin extension\", () => {\n const Mixin = <const S extends DiscriminatedUnionConfiguration>(\n config: S,\n ) => {\n abstract class Mix extends DiscriminatedUnion(config) {\n deep = true as const;\n static deep = true as const;\n abstract abstract: true;\n }\n\n return Mix;\n };\n\n class A extends Dict({ type: \"A\" }) {}\n class B extends Dict({ type: \"B\" }) {}\n\n class Test extends Mixin([A, B]) {\n test = true as const;\n\n // @ts-expect-error is not assignable to parameter of type 'true'\n abstract = false as const;\n }\n\n type Serialized = { type: \"A\" } | { type: \"B\" };\n\n // Constructor parameters\n ex(Test).toHaveFirstParam<A | B>().ok;\n\n // Additional static prototype\n ex(Test.deep).toBe(true as const).ok;\n\n // Deserialization\n ex(Test.deserialize).toHaveFirstParam<Serialized>().ok;\n const a = Test.deserialize({ type: \"A\" });\n ex(a).toBeInstanceOf(Test).ok;\n\n // Additional prototype on deserialization\n ex(a.test).toBe(true as const).ok;\n ex(a.abstract).toBe(false as const).ok;\n\n // Extended prototype on deserialization\n ex(a.deep).toBe(true as const).ok;\n\n // Inherited prototype on deserialization\n ex(a.value).toStrictEqual<A | B>(new A({ type: \"A\" })).ok;\n\n // Serialization\n ex(a.serialize()).toStrictEqual<Serialized>({ type: \"A\" }).ok;\n\n // Instantiation\n const b = new Test(new B({ type: \"B\" }));\n ex(b).toBeInstanceOf(Test).ok;\n\n // Additional prototype on instantiation\n ex(b.test).toBe(true as const).ok;\n ex(b.abstract).toBe(false as const).ok;\n\n // Extended prototype on instantiation\n ex(b.deep).toBe(true as const).ok;\n\n // Inherited prototype on instantiation\n ex(b.value).toStrictEqual<A | B>(new B({ type: \"B\" })).ok;\n });\n\n it(\"mixin supersede\", () => {\n const Testable = <const C extends DiscriminatedUnionConfiguration>(\n config: C,\n ) => {\n abstract class I {\n deep = true as const;\n static deep = true as const;\n\n abstract abstract: true;\n }\n\n return DiscriminatedUnion(config, I);\n };\n\n class A extends Dict({ type: \"A\" }) {}\n class B extends Dict({ type: \"B\" }) {}\n\n class Test extends Testable([A, B]) {\n test = true as const;\n\n // @ts-expect-error is not assignable to parameter of type 'true'\n abstract = false as const;\n }\n\n // Constructor type\n ex(Test).toHaveFirstParam<A | B>().ok;\n\n // Additional static prototype\n ex(Test.deep).toBe(true as const).ok;\n\n type Serialized = { type: \"A\" } | { type: \"B\" };\n\n // Deserialization\n ex(Test.deserialize).toHaveFirstParam<Serialized>().ok;\n const a = Test.deserialize({ type: \"A\" });\n ex(a).toBeInstanceOf(Test).ok;\n\n // Additional prototype on deserialization\n ex(a.test).toBe(true as const).ok;\n ex(a.abstract).toBe(false as const).ok;\n\n // Superseded prototype on deserialization\n ex(a.deep).toBe(true as const).ok;\n\n // Inherited prototype on deserialization\n ex(a.value).toStrictEqual<A | B>(new A({ type: \"A\" })).ok;\n\n // Serialization\n ex(a.serialize()).toStrictEqual<Serialized>({\n type: \"A\",\n }).ok;\n\n // Instantiation\n const b = new Test(new B({ type: \"B\" }));\n ex(b).toBeInstanceOf(Test).ok;\n\n // Additional prototype on instantiation\n ex(b.test).toBe(true as const).ok;\n ex(b.abstract).toBe(false as const).ok;\n\n // Superseded prototype on instantiation\n ex(b.deep).toBe(true as const).ok;\n ex(b.abstract).toBe(false as const).ok;\n\n // Inherited prototype on instantiation\n ex(b.value).toStrictEqual<A | B>(new B({ type: \"B\" })).ok;\n });\n});\n\n// making the config `as const` breaks the freeze command\n// This enforces the use of `as const` in the discriminator\n// This is ugly\nclass A extends DiscriminatedUnion([\n { type: \"A\" as const },\n { type: \"B\" as const },\n]) {}\nconst _shouldBeFreezable: Equals<\n (typeof A)[\"$of\"],\n ({ type: \"A\" } | { type: \"B\" })[]\n> = true;\n"]}
|
package/dist/either.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Constructor, Expand, DefinitionOf, AbstractConstructor, Empty } from "./_";
|
|
2
|
-
import { ClassShorthand } from "./class";
|
|
3
|
-
type Config = {
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
};
|
|
6
|
-
type ExhaustiveMatcher<C extends Config> = {
|
|
7
|
-
[key in keyof C]: (value: InstanceType<C[key]>) => any;
|
|
8
|
-
};
|
|
9
|
-
type UnsafeFallthroughMatcher<C extends Config> = {
|
|
10
|
-
[key in keyof C]?: (value: InstanceType<C[key]>) => any;
|
|
11
|
-
} & {
|
|
12
|
-
_: (value: InstanceType<C[keyof C]>) => any;
|
|
13
|
-
};
|
|
14
|
-
type PartialMatcher<C extends Config> = {
|
|
15
|
-
[key in keyof C]?: (value: InstanceType<C[key]>) => any;
|
|
16
|
-
};
|
|
17
|
-
type Matcher<C extends Config> = ExhaustiveMatcher<C> | UnsafeFallthroughMatcher<C> | PartialMatcher<C>;
|
|
18
|
-
export type EitherConfiguration = {
|
|
19
|
-
[key: string]: ClassShorthand;
|
|
20
|
-
};
|
|
21
|
-
type Internal<S extends EitherConfiguration, B extends AbstractConstructor<{}>> = {
|
|
22
|
-
Definition: DefinitionOf<S[keyof S]>;
|
|
23
|
-
Serialized: (B extends {
|
|
24
|
-
$name: infer U;
|
|
25
|
-
} ? {
|
|
26
|
-
$name: U;
|
|
27
|
-
} : {}) & {
|
|
28
|
-
_key: keyof S;
|
|
29
|
-
} & ReturnType<DefinitionOf<S[keyof S]>["$serialize"]>;
|
|
30
|
-
Deserializing: (B extends {
|
|
31
|
-
$name: infer U;
|
|
32
|
-
} ? {
|
|
33
|
-
$name: U;
|
|
34
|
-
} : {}) & {
|
|
35
|
-
_key: keyof S;
|
|
36
|
-
} & Parameters<DefinitionOf<S[keyof S]>["$deserialize"]>[0];
|
|
37
|
-
Inline: DefinitionOf<S[keyof S]>["$inline"];
|
|
38
|
-
};
|
|
39
|
-
export declare const Either: <const S extends EitherConfiguration, const B extends AbstractConstructor<{}> = typeof Empty>(of: S, base?: B) => Omit<B, "prototype"> & Omit<(abstract new (value: DefinitionOf<S[keyof S]>["$inline"]) => {
|
|
40
|
-
value: DefinitionOf<S[keyof S], typeof Empty>["$inline"];
|
|
41
|
-
serialize(): Expand<{ [K in keyof S]: {
|
|
42
|
-
_key: K;
|
|
43
|
-
} & ReturnType<DefinitionOf<S[K]>["$serialize"]>; }[keyof S]>;
|
|
44
|
-
match<M extends Matcher<S>, F extends M extends ExhaustiveMatcher<S> ? [] : M extends UnsafeFallthroughMatcher<S> ? [] : M extends PartialMatcher<S> ? [fallback: (value: InstanceType<Omit<S, keyof M>[keyof Omit<S, keyof M>]>) => any] : []>(matcher: M, ...fallback_n: F): (M[keyof M] extends (...args: any[]) => any ? ReturnType<M[keyof M]> : never) | (F[0] extends (...args: any[]) => any ? ReturnType<F[0]> : never);
|
|
45
|
-
}) & {
|
|
46
|
-
serialized: { [K in keyof S]: {
|
|
47
|
-
_key: K;
|
|
48
|
-
} & ReturnType<DefinitionOf<S[K]>["$serialize"]>; }[keyof S];
|
|
49
|
-
of: S;
|
|
50
|
-
$shape: "either";
|
|
51
|
-
deserialize<T extends /*elided*/ any>(this: T, value: Expand<{ [K in keyof S]: {
|
|
52
|
-
_key: K;
|
|
53
|
-
} & ReturnType<DefinitionOf<S[K]>["$serialize"]>; }[keyof S]>): InstanceType<T>;
|
|
54
|
-
$deserialize<T extends /*elided*/ any>(this: T, value: { [K in keyof S]: {
|
|
55
|
-
_key: K;
|
|
56
|
-
} & ReturnType<DefinitionOf<S[K]>["$serialize"]>; }[keyof S]): DefinitionOf<S[keyof S]>["$inline"];
|
|
57
|
-
$serialize<T extends /*elided*/ any>(this: T, value: DefinitionOf<S[keyof S]>["$inline"]): { [K in keyof S]: {
|
|
58
|
-
_key: K;
|
|
59
|
-
} & ReturnType<DefinitionOf<S[K]>["$serialize"]>; }[keyof S];
|
|
60
|
-
$inline: DefinitionOf<S[keyof S]>["$inline"];
|
|
61
|
-
}, "prototype"> & (abstract new (value: Expand<DefinitionOf<S[keyof S]>["$inline"]>) => InstanceType<B> & {
|
|
62
|
-
value: DefinitionOf<S[keyof S], typeof Empty>["$inline"];
|
|
63
|
-
serialize(): Expand<{ [K in keyof S]: {
|
|
64
|
-
_key: K;
|
|
65
|
-
} & ReturnType<DefinitionOf<S[K]>["$serialize"]>; }[keyof S]>;
|
|
66
|
-
match<M extends Matcher<S>, F extends M extends ExhaustiveMatcher<S> ? [] : M extends UnsafeFallthroughMatcher<S> ? [] : M extends PartialMatcher<S> ? [fallback: (value: InstanceType<Omit<S, keyof M>[keyof Omit<S, keyof M>]>) => any] : []>(matcher: M, ...fallback_n: F): (M[keyof M] extends (...args: any[]) => any ? ReturnType<M[keyof M]> : never) | (F[0] extends (...args: any[]) => any ? ReturnType<F[0]> : never);
|
|
67
|
-
});
|
|
68
|
-
export type Either<S extends EitherConfiguration, B extends AbstractConstructor<{}> = typeof Empty> = Omit<B, "prototype"> & (abstract new (value: Internal<S, B>["Inline"]) => {
|
|
69
|
-
value: Internal<S, B>["Inline"];
|
|
70
|
-
serialize(): Internal<S, B>["Serialized"];
|
|
71
|
-
match<M extends Matcher<S>, F extends M extends ExhaustiveMatcher<S> ? [] : M extends UnsafeFallthroughMatcher<S> ? [] : M extends PartialMatcher<S> ? [
|
|
72
|
-
fallback: (value: InstanceType<Omit<S, keyof M>[keyof Omit<S, keyof M>]>) => any
|
|
73
|
-
] : []>(matcher: M, ...fallback_n: F): (M[keyof M] extends (...args: any[]) => any ? ReturnType<M[keyof M]> : never) | (F[0] extends (...args: any[]) => any ? ReturnType<F[0]> : never);
|
|
74
|
-
}) & {
|
|
75
|
-
serialized: Internal<S, B>["Serialized"];
|
|
76
|
-
of: S;
|
|
77
|
-
$shape: "either";
|
|
78
|
-
deserialize<T extends Constructor>(this: T, value: Internal<S, B>["Serialized"]): InstanceType<T>;
|
|
79
|
-
$deserialize<T>(this: T, value: Internal<S, B>["Serialized"]): Internal<S, B>["Inline"];
|
|
80
|
-
$serialize<T>(this: T, value: Internal<S, B>["Inline"]): Internal<S, B>["Serialized"];
|
|
81
|
-
$inline: Internal<S, B>["Inline"];
|
|
82
|
-
};
|
|
83
|
-
export {};
|
|
84
|
-
//# sourceMappingURL=either.d.ts.map
|
package/dist/either.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"either.d.ts","sourceRoot":"","sources":["../src/either.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,MAAM,EACN,YAAY,EAEZ,mBAAmB,EACnB,KAAK,EACN,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,KAAK,MAAM,GAAG;IAAE,CAAC,GAAG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GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;CACvE,CAAC,GAAG;IACH,UAAU,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACzC,EAAE,EAAE,CAAC,CAAC;IACN,MAAM,EAAE,QAAQ,CAAC;IACjB,WAAW,CAAC,CAAC,SAAS,WAAW,EAC/B,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,GAClC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnB,YAAY,CAAC,CAAC,EACZ,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,GAClC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC5B,UAAU,CAAC,CAAC,EACV,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,GAC9B,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAChC,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CACnC,CAAC"}
|
package/dist/either.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Either = void 0;
|
|
4
|
-
const _1 = require("./_");
|
|
5
|
-
const Either = (of, base = _1.Empty) => {
|
|
6
|
-
const definitions = Object.fromEntries(Object.entries(of).map(([key, value]) => {
|
|
7
|
-
return [key, (0, _1.Shape)(value)];
|
|
8
|
-
}));
|
|
9
|
-
class $Either extends base {
|
|
10
|
-
value;
|
|
11
|
-
constructor(value) {
|
|
12
|
-
super();
|
|
13
|
-
this.value = value;
|
|
14
|
-
}
|
|
15
|
-
static serialized;
|
|
16
|
-
static of = of;
|
|
17
|
-
static $shape = "either";
|
|
18
|
-
serialize() {
|
|
19
|
-
return $Either.$serialize(this.value);
|
|
20
|
-
}
|
|
21
|
-
match(...[matcher, fallback]) {
|
|
22
|
-
const key = Object.entries(of).find(([_, v]) => v === this.value.constructor)?.[0];
|
|
23
|
-
const handler = matcher[key];
|
|
24
|
-
if (handler) {
|
|
25
|
-
return handler(this.value);
|
|
26
|
-
}
|
|
27
|
-
if (fallback) {
|
|
28
|
-
return fallback(this.value);
|
|
29
|
-
}
|
|
30
|
-
if (matcher._) {
|
|
31
|
-
return matcher._(this.value);
|
|
32
|
-
}
|
|
33
|
-
throw new Error("Non-exhaustive match");
|
|
34
|
-
}
|
|
35
|
-
static deserialize(value) {
|
|
36
|
-
return new this(this.$deserialize(value));
|
|
37
|
-
}
|
|
38
|
-
static $deserialize(value) {
|
|
39
|
-
const { _key: key, ...serialized } = value;
|
|
40
|
-
const definition = definitions[key];
|
|
41
|
-
if (!definition) {
|
|
42
|
-
throw new Error("Cannot deserialize Either");
|
|
43
|
-
}
|
|
44
|
-
return definition.$deserialize(serialized);
|
|
45
|
-
}
|
|
46
|
-
static $serialize(value) {
|
|
47
|
-
const key = Object.entries(of).find(([_, v]) => v === value.constructor)?.[0];
|
|
48
|
-
if (!key) {
|
|
49
|
-
throw new Error("Cannot serialize Either, no matching key");
|
|
50
|
-
}
|
|
51
|
-
const definition = definitions[key];
|
|
52
|
-
if (!definition) {
|
|
53
|
-
throw new Error("Cannot serialize Either");
|
|
54
|
-
}
|
|
55
|
-
return { ...definition.$serialize(value), _key: key };
|
|
56
|
-
}
|
|
57
|
-
static $inline;
|
|
58
|
-
}
|
|
59
|
-
return $Either;
|
|
60
|
-
};
|
|
61
|
-
exports.Either = Either;
|
|
62
|
-
//# sourceMappingURL=either.js.map
|
package/dist/either.js.map
DELETED
|
@@ -1 +0,0 @@
|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E,IAAI,EAAE,GAAG,EAAS,CAAC;QACxE,CAAC;QAED,MAAM,CAAC,OAAO,CAAS;;IAUzB,OAAO,OAAiB,CAAC;AAC3B,CAAC,CAAC;AAvHW,QAAA,MAAM,UAuHjB","sourcesContent":["import {\n Constructor,\n Expand,\n DefinitionOf,\n Shape,\n AbstractConstructor,\n Empty,\n} from \"./_\";\nimport { ClassShorthand } from \"./class\";\nimport { PrimitiveShorthand } from \"./primitive\";\n\ntype Config = { [key: string]: any };\n\ntype ExhaustiveMatcher<C extends Config> = {\n [key in keyof C]: (value: InstanceType<C[key]>) => any;\n};\n\ntype UnsafeFallthroughMatcher<C extends Config> = {\n [key in keyof C]?: (value: InstanceType<C[key]>) => any;\n} & {\n _: (value: InstanceType<C[keyof C]>) => any;\n};\n\ntype PartialMatcher<C extends Config> = {\n [key in keyof C]?: (value: InstanceType<C[key]>) => any;\n};\n\ntype Matcher<C extends Config> =\n | ExhaustiveMatcher<C>\n | UnsafeFallthroughMatcher<C>\n | PartialMatcher<C>;\n\nexport type EitherConfiguration = {\n [key: string]: ClassShorthand;\n};\n\ntype Internal<\n S extends EitherConfiguration,\n B extends AbstractConstructor<{}>,\n> = {\n Definition: DefinitionOf<S[keyof S]>;\n Serialized: (B extends { $name: infer U } ? { $name: U } : {}) & {\n _key: keyof S;\n } & ReturnType<DefinitionOf<S[keyof S]>[\"$serialize\"]>;\n Deserializing: (B extends { $name: infer U } ? { $name: U } : {}) & {\n _key: keyof S;\n } & Parameters<DefinitionOf<S[keyof S]>[\"$deserialize\"]>[0];\n Inline: DefinitionOf<S[keyof S]>[\"$inline\"];\n};\n\nexport const Either = <\n const S extends EitherConfiguration,\n const B extends AbstractConstructor<{}> = typeof Empty,\n>(\n of: S,\n base: B = Empty as any,\n) => {\n type Serialized = {\n [K in keyof S]: { _key: K } & ReturnType<DefinitionOf<S[K]>[\"$serialize\"]>;\n }[keyof S];\n\n type Inline = DefinitionOf<S[keyof S]>[\"$inline\"];\n\n const definitions = Object.fromEntries(\n Object.entries(of).map(([key, value]) => {\n return [key, Shape(value)] as const;\n }),\n );\n\n abstract class $Either extends (base as any as Constructor<{}>) {\n constructor(public value: Inline) {\n super();\n }\n\n static serialized: Serialized;\n\n static of = of;\n\n static $shape = \"either\" as const;\n\n serialize(): Expand<Serialized> {\n return ($Either as any).$serialize(this.value) as any;\n }\n\n match<\n M extends Matcher<S>,\n F extends M extends ExhaustiveMatcher<S>\n ? []\n : M extends UnsafeFallthroughMatcher<S>\n ? []\n : M extends PartialMatcher<S>\n ? [\n fallback: (\n value: InstanceType<Omit<S, keyof M>[keyof Omit<S, keyof M>]>,\n ) => any,\n ]\n : [],\n >(\n ...[matcher, fallback]: [matcher: M, ...F]\n ):\n | (M[keyof M] extends (...args: any[]) => any\n ? ReturnType<M[keyof M]>\n : never)\n | (F[0] extends (...args: any[]) => any ? ReturnType<F[0]> : never) {\n const key: any = Object.entries(of).find(\n ([_, v]) => v === ((this.value as any).constructor as any),\n )?.[0] as any;\n\n const handler = matcher[key];\n if (handler) {\n return handler(this.value as any);\n }\n if (fallback) {\n return fallback(this.value as any);\n }\n if (matcher._) {\n return matcher._(this.value as any);\n }\n throw new Error(\"Non-exhaustive match\");\n }\n\n static deserialize<T extends typeof $Either>(\n this: T,\n value: Expand<Serialized>,\n ): InstanceType<T> {\n return new (this as any)(this.$deserialize(value as any)) as any;\n }\n\n static $deserialize<T extends typeof $Either>(\n this: T,\n value: Serialized,\n ): Inline {\n const { _key: key, ...serialized } = value as any;\n const definition = definitions[key];\n if (!definition) {\n throw new Error(\"Cannot deserialize Either\");\n }\n return (definition as any).$deserialize(serialized);\n }\n\n static $serialize<T extends typeof $Either>(\n this: T,\n value: Inline,\n ): Serialized {\n const key = Object.entries(of).find(\n ([_, v]) => v === ((value as any).constructor as any),\n )?.[0];\n if (!key) {\n throw new Error(\"Cannot serialize Either, no matching key\");\n }\n\n const definition = definitions[key];\n if (!definition) {\n throw new Error(\"Cannot serialize Either\");\n }\n return { ...(definition as any).$serialize(value), _key: key } as any;\n }\n\n static $inline: Inline;\n }\n\n type EitherConstructor = abstract new (\n value: Expand<Inline>,\n ) => InstanceType<B> & $Either;\n type Either = Omit<B, \"prototype\"> &\n Omit<typeof $Either, \"prototype\"> &\n EitherConstructor;\n\n return $Either as Either;\n};\n\nexport type Either<\n S extends EitherConfiguration,\n B extends AbstractConstructor<{}> = typeof Empty,\n> = Omit<B, \"prototype\"> &\n (abstract new (\n value: Internal<S, B>[\"Inline\"],\n ) => {\n value: Internal<S, B>[\"Inline\"];\n serialize(): Internal<S, B>[\"Serialized\"];\n match<\n M extends Matcher<S>,\n F extends M extends ExhaustiveMatcher<S>\n ? []\n : M extends UnsafeFallthroughMatcher<S>\n ? []\n : M extends PartialMatcher<S>\n ? [\n fallback: (\n value: InstanceType<Omit<S, keyof M>[keyof Omit<S, keyof M>]>,\n ) => any,\n ]\n : [],\n >(\n matcher: M,\n ...fallback_n: F\n ):\n | (M[keyof M] extends (...args: any[]) => any\n ? ReturnType<M[keyof M]>\n : never)\n | (F[0] extends (...args: any[]) => any ? ReturnType<F[0]> : never);\n }) & {\n serialized: Internal<S, B>[\"Serialized\"];\n of: S;\n $shape: \"either\";\n deserialize<T extends Constructor>(\n this: T,\n value: Internal<S, B>[\"Serialized\"],\n ): InstanceType<T>;\n $deserialize<T>(\n this: T,\n value: Internal<S, B>[\"Serialized\"],\n ): Internal<S, B>[\"Inline\"];\n $serialize<T>(\n this: T,\n value: Internal<S, B>[\"Inline\"],\n ): Internal<S, B>[\"Serialized\"];\n $inline: Internal<S, B>[\"Inline\"];\n };\n"]}
|
package/dist/either.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"either.spec.d.ts","sourceRoot":"","sources":["../src/either.spec.ts"],"names":[],"mappings":""}
|