@ddd-ts/shape 0.0.37 → 0.0.39

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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_.d.ts +39 -0
  3. package/dist/_.d.ts.map +1 -0
  4. package/dist/_.js +38 -0
  5. package/dist/_.mjs +36 -0
  6. package/dist/addons/microsecond-timestamp.d.ts +24 -0
  7. package/dist/addons/microsecond-timestamp.d.ts.map +1 -0
  8. package/dist/addons/microsecond-timestamp.js +62 -0
  9. package/dist/addons/microsecond-timestamp.mjs +61 -0
  10. package/dist/choice.d.ts +30 -0
  11. package/dist/choice.d.ts.map +1 -0
  12. package/dist/choice.js +44 -0
  13. package/dist/choice.mjs +44 -0
  14. package/dist/choice.spec.d.ts +2 -0
  15. package/dist/choice.spec.d.ts.map +1 -0
  16. package/dist/class.d.ts +23 -0
  17. package/dist/class.d.ts.map +1 -0
  18. package/dist/class.js +30 -0
  19. package/dist/class.mjs +30 -0
  20. package/dist/class.spec.d.ts +2 -0
  21. package/dist/class.spec.d.ts.map +1 -0
  22. package/dist/dict.d.ts +43 -0
  23. package/dist/dict.d.ts.map +1 -0
  24. package/dist/dict.js +41 -0
  25. package/dist/dict.mjs +41 -0
  26. package/dist/dict.spec.d.ts +2 -0
  27. package/dist/dict.spec.d.ts.map +1 -0
  28. package/dist/discriminated-union.d.ts +74 -0
  29. package/dist/discriminated-union.d.ts.map +1 -0
  30. package/dist/discriminated-union.js +66 -0
  31. package/dist/discriminated-union.mjs +64 -0
  32. package/dist/discriminated-union.spec.d.ts +2 -0
  33. package/dist/discriminated-union.spec.d.ts.map +1 -0
  34. package/dist/either.d.ts +84 -0
  35. package/dist/either.d.ts.map +1 -0
  36. package/dist/either.js +51 -0
  37. package/dist/either.mjs +51 -0
  38. package/dist/either.spec.d.ts +2 -0
  39. package/dist/either.spec.d.ts.map +1 -0
  40. package/dist/index.d.ts +14 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +32 -0
  43. package/dist/index.mjs +15 -0
  44. package/dist/literal.d.ts +15 -0
  45. package/dist/literal.d.ts.map +1 -0
  46. package/dist/literal.js +27 -0
  47. package/dist/literal.mjs +27 -0
  48. package/dist/literal.spec.d.ts +2 -0
  49. package/dist/literal.spec.d.ts.map +1 -0
  50. package/dist/mapping.d.ts +43 -0
  51. package/dist/mapping.d.ts.map +1 -0
  52. package/dist/mapping.js +45 -0
  53. package/dist/mapping.mjs +45 -0
  54. package/dist/mapping.spec.d.ts +2 -0
  55. package/dist/mapping.spec.d.ts.map +1 -0
  56. package/dist/multiple.d.ts +20 -0
  57. package/dist/multiple.d.ts.map +1 -0
  58. package/dist/multiple.js +119 -0
  59. package/dist/multiple.mjs +119 -0
  60. package/dist/multiple.spec.d.ts +2 -0
  61. package/dist/multiple.spec.d.ts.map +1 -0
  62. package/dist/nothing.d.ts +14 -0
  63. package/dist/nothing.d.ts.map +1 -0
  64. package/dist/nothing.js +19 -0
  65. package/dist/nothing.mjs +19 -0
  66. package/dist/nothing.spec.d.ts +2 -0
  67. package/dist/nothing.spec.d.ts.map +1 -0
  68. package/dist/optional.d.ts +26 -0
  69. package/dist/optional.d.ts.map +1 -0
  70. package/dist/optional.js +34 -0
  71. package/dist/optional.mjs +34 -0
  72. package/dist/optional.spec.d.ts +2 -0
  73. package/dist/optional.spec.d.ts.map +1 -0
  74. package/dist/primitive.d.ts +38 -0
  75. package/dist/primitive.d.ts.map +1 -0
  76. package/dist/primitive.js +30 -0
  77. package/dist/primitive.mjs +30 -0
  78. package/dist/primitive.spec.d.ts +2 -0
  79. package/dist/primitive.spec.d.ts.map +1 -0
  80. package/dist/test.d.ts +36 -0
  81. package/dist/test.d.ts.map +1 -0
  82. package/package.json +17 -15
@@ -0,0 +1,43 @@
1
+ import { type Definition, type Expand, type Shorthand, type DefinitionOf, type AbstractConstructor, Empty, type Constructor } from "./_";
2
+ type MappingLiteralKey = [
3
+ [
4
+ StringConstructor,
5
+ string
6
+ ],
7
+ [
8
+ NumberConstructor,
9
+ number
10
+ ]
11
+ ];
12
+ type MappingKeyConstructor = MappingLiteralKey[number][0];
13
+ type MappingKeyRuntimeFromConstructor<S extends MappingKeyConstructor> = S extends StringConstructor ? string : number;
14
+ export type MappingConfiguration = [MappingKeyConstructor, Definition | Shorthand] | [Definition | Shorthand];
15
+ type MappingOf<C extends MappingConfiguration> = C extends [
16
+ infer K extends MappingKeyConstructor,
17
+ infer V extends Definition | Shorthand
18
+ ] ? {
19
+ key: K;
20
+ value: DefinitionOf<V>;
21
+ } : C extends [infer V extends Definition | Shorthand] ? {
22
+ key: StringConstructor;
23
+ value: DefinitionOf<V>;
24
+ } : never;
25
+ type Internal<C extends MappingConfiguration, B extends AbstractConstructor<{}>> = {
26
+ Definition: MappingOf<C>["value"];
27
+ Serialized: Record<MappingKeyRuntimeFromConstructor<MappingOf<C>["key"]>, ReturnType<MappingOf<C>["value"]["$serialize"]>>;
28
+ Deserializing: Record<MappingKeyRuntimeFromConstructor<MappingOf<C>["key"]>, Parameters<MappingOf<C>["value"]["$deserialize"]>[0]>;
29
+ Inline: Record<MappingKeyRuntimeFromConstructor<MappingOf<C>["key"]>, MappingOf<C>["value"]["$inline"]>;
30
+ };
31
+ export declare const Mapping: <C extends MappingConfiguration, B extends AbstractConstructor<{}> = typeof Empty>(config: C, base?: B) => Mapping<C, B>;
32
+ export type Mapping<C extends MappingConfiguration, B extends AbstractConstructor<{}> = typeof Empty> = Omit<B, "prototype"> & (abstract new (value: Internal<C, B>["Inline"]) => InstanceType<B> & {
33
+ value: Internal<C, B>["Inline"];
34
+ serialize(): Expand<Internal<C, B>["Serialized"]>;
35
+ }) & {
36
+ $shape: "mapping";
37
+ deserialize<T extends Constructor>(this: T, value: Expand<Internal<C, B>["Serialized"]>): InstanceType<T>;
38
+ $deserialize<T>(this: T, value: Internal<C, B>["Deserializing"]): Internal<C, B>["Inline"];
39
+ $serialize<T>(this: T, value: Internal<C, B>["Inline"]): Internal<C, B>["Serialized"];
40
+ $inline: Internal<C, B>["Inline"];
41
+ };
42
+ export {};
43
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,YAAY,EAEjB,KAAK,mBAAmB,EACxB,KAAK,EACL,KAAK,WAAW,EACjB,MAAM,KAAK,CAAC;AAGb,KAAK,iBAAiB,GAAG;IACvB;QAAC,iBAAiB;QAAE,MAAM;KAAC;IAC3B;QAAC,iBAAiB;QAAE,MAAM;KAAC;CAC5B,CAAC;AACF,KAAK,qBAAqB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,KAAK,gCAAgC,CAAC,CAAC,SAAS,qBAAqB,IACnE,CAAC,SAAS,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAC5B,CAAC,qBAAqB,EAAE,UAAU,GAAG,SAAS,CAAC,GAC/C,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;AAE7B,KAAK,SAAS,CAAC,CAAC,SAAS,oBAAoB,IAAI,CAAC,SAAS;IACzD,MAAM,CAAC,SAAS,qBAAqB;IACrC,MAAM,CAAC,SAAS,UAAU,GAAG,SAAS;CACvC,GACG;IAAE,GAAG,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;CAAE,GAClC,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,UAAU,GAAG,SAAS,CAAC,GAChD;IAAE,GAAG,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;CAAE,GAClD,KAAK,CAAC;AAEZ,KAAK,QAAQ,CACX,CAAC,SAAS,oBAAoB,EAC9B,CAAC,S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AI,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;CACnD,CAAC,GAAG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,CAAC,SAAS,WAAW,EAC/B,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,GAC1C,YAAY,CAAC,CAAC,CAAC,CAAC;IACnB,YAAY,CAAC,CAAC,EACZ,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,GACrC,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"}
@@ -0,0 +1,45 @@
1
+ const require_primitive = require('./primitive.js');
2
+ const require__ = require('./_.js');
3
+
4
+ //#region src/mapping.ts
5
+ const Mapping = (config, base = require__.Empty) => {
6
+ let [_key, _value] = config;
7
+ if (config.length === 1) {
8
+ _key = require_primitive.Primitive(String);
9
+ _value = config[0];
10
+ }
11
+ const { $key, $value } = {
12
+ $key: _key,
13
+ $value: _value
14
+ };
15
+ class $Mapping extends base {
16
+ constructor(value) {
17
+ super();
18
+ this.value = value;
19
+ }
20
+ static $shape = "mapping";
21
+ serialize() {
22
+ return $Mapping.$serialize(this.value);
23
+ }
24
+ static deserialize(value) {
25
+ return new this($Mapping.$deserialize(value));
26
+ }
27
+ static $deserialize(value) {
28
+ const transform = Object.entries(value).map(([key, child]) => {
29
+ return [key, require__.Shape(_value).$deserialize(child)];
30
+ });
31
+ return Object.fromEntries(transform);
32
+ }
33
+ static $serialize(value) {
34
+ const transform = Object.entries(value).map(([key, child]) => {
35
+ return [key, require__.Shape($value).$serialize(child)];
36
+ });
37
+ return Object.fromEntries(transform);
38
+ }
39
+ static $inline;
40
+ }
41
+ return $Mapping;
42
+ };
43
+
44
+ //#endregion
45
+ exports.Mapping = Mapping;
@@ -0,0 +1,45 @@
1
+ import { Primitive } from "./primitive.mjs";
2
+ import { Empty, Shape } from "./_.mjs";
3
+
4
+ //#region src/mapping.ts
5
+ const Mapping = (config, base = Empty) => {
6
+ let [_key, _value] = config;
7
+ if (config.length === 1) {
8
+ _key = Primitive(String);
9
+ _value = config[0];
10
+ }
11
+ const { $key, $value } = {
12
+ $key: _key,
13
+ $value: _value
14
+ };
15
+ class $Mapping extends base {
16
+ constructor(value) {
17
+ super();
18
+ this.value = value;
19
+ }
20
+ static $shape = "mapping";
21
+ serialize() {
22
+ return $Mapping.$serialize(this.value);
23
+ }
24
+ static deserialize(value) {
25
+ return new this($Mapping.$deserialize(value));
26
+ }
27
+ static $deserialize(value) {
28
+ const transform = Object.entries(value).map(([key, child]) => {
29
+ return [key, Shape(_value).$deserialize(child)];
30
+ });
31
+ return Object.fromEntries(transform);
32
+ }
33
+ static $serialize(value) {
34
+ const transform = Object.entries(value).map(([key, child]) => {
35
+ return [key, Shape($value).$serialize(child)];
36
+ });
37
+ return Object.fromEntries(transform);
38
+ }
39
+ static $inline;
40
+ }
41
+ return $Mapping;
42
+ };
43
+
44
+ //#endregion
45
+ export { Mapping };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mapping.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.spec.d.ts","sourceRoot":"","sources":["../src/mapping.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { type Definition, type Expand, type Shorthand, type DefinitionOf, type AbstractConstructor, Empty, type Constructor } from "./_";
2
+ export type MultipleConfiguration = Definition | Shorthand;
3
+ export type MultipleShorthand = [any] | readonly [any];
4
+ type Internal<S extends MultipleConfiguration> = {
5
+ Serialized: ReturnType<DefinitionOf<S>["$serialize"]>[];
6
+ Inline: DefinitionOf<S>["$inline"][];
7
+ };
8
+ export declare const Multiple: <const S extends MultipleConfiguration, B extends AbstractConstructor<{}> = typeof Empty>(of: S, base?: B) => IMultiple<S, B>;
9
+ export type IMultiple<S extends MultipleConfiguration, B extends AbstractConstructor<{}> = typeof Empty> = Omit<B, "prototype"> & (abstract new (value: Internal<S>["Inline"]) => InstanceType<B> & Pick<Internal<S>["Inline"], "at" | "length" | "concat" | "copyWithin" | "entries" | "every" | "fill" | "filter" | "find" | "findIndex" | "flat" | "flatMap" | "forEach" | "includes" | "indexOf" | "join" | "keys" | "lastIndexOf" | "map" | "pop" | "push" | "reduce" | "reduceRight" | "reverse" | "shift" | "slice" | "some" | "sort" | "splice" | "unshift" | "values" | typeof Symbol.iterator> & {
10
+ value: Internal<S>["Inline"];
11
+ serialize(): Expand<Internal<S>["Serialized"]>;
12
+ }) & {
13
+ $shape: "multiple";
14
+ deserialize<T extends Constructor>(this: T, value: Expand<Internal<S>["Serialized"]>): InstanceType<T>;
15
+ $deserialize<T extends Constructor>(this: T, value: Internal<S>["Serialized"]): InstanceType<T>;
16
+ $serialize(value: Internal<S>["Inline"]): Internal<S>["Serialized"];
17
+ $inline: Internal<S>["Inline"];
18
+ };
19
+ export {};
20
+ //# sourceMappingURL=multiple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiple.d.ts","sourceRoot":"","sources":["../src/multiple.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,YAAY,EAEjB,KAAK,mBAAmB,EACxB,KAAK,EACL,KAAK,WAAW,EACjB,MAAM,KAAK,CA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,MAAM,CAAC,QAAQ,CACzB,GAAG;IACF,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC7B,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;CAChD,CAAC,GAAG;IACL,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,CAAC,SAAS,WAAW,EAC/B,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,GACvC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnB,YAAY,CAAC,CAAC,SAAS,WAAW,EAChC,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,GAC/B,YAAY,CAAC,CAAC,CAAC,CAAC;IACnB,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACpE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CAChC,CAAC"}
@@ -0,0 +1,119 @@
1
+ const require__ = require('./_.js');
2
+
3
+ //#region src/multiple.ts
4
+ const Multiple = (of, base = require__.Empty) => {
5
+ const longhand = require__.Shape(of);
6
+ class $Multiple extends base {
7
+ constructor(value) {
8
+ super();
9
+ this.value = value;
10
+ }
11
+ static $shape = "multiple";
12
+ serialize() {
13
+ return $Multiple.$serialize(this.value);
14
+ }
15
+ static deserialize(value) {
16
+ return new this($Multiple.$deserialize(value));
17
+ }
18
+ static $deserialize(value) {
19
+ return value.map(longhand.$deserialize);
20
+ }
21
+ static $serialize(value) {
22
+ return value.map(longhand.$serialize);
23
+ }
24
+ [Symbol.iterator]() {
25
+ return this.value[Symbol.iterator]();
26
+ }
27
+ get map() {
28
+ return this.value.map.bind(this.value);
29
+ }
30
+ get reduce() {
31
+ return this.value.reduce.bind(this.value);
32
+ }
33
+ get filter() {
34
+ return this.value.filter.bind(this.value);
35
+ }
36
+ get forEach() {
37
+ return this.value.forEach.bind(this.value);
38
+ }
39
+ get some() {
40
+ return this.value.some.bind(this.value);
41
+ }
42
+ get every() {
43
+ return this.value.every.bind(this.value);
44
+ }
45
+ get find() {
46
+ return this.value.find.bind(this.value);
47
+ }
48
+ get findIndex() {
49
+ return this.value.findIndex.bind(this.value);
50
+ }
51
+ get indexOf() {
52
+ return this.value.indexOf.bind(this.value);
53
+ }
54
+ get lastIndexOf() {
55
+ return this.value.lastIndexOf.bind(this.value);
56
+ }
57
+ get includes() {
58
+ return this.value.includes.bind(this.value);
59
+ }
60
+ get keys() {
61
+ return this.value.keys.bind(this.value);
62
+ }
63
+ get values() {
64
+ return this.value.values.bind(this.value);
65
+ }
66
+ get entries() {
67
+ return this.value.entries.bind(this.value);
68
+ }
69
+ get at() {
70
+ return this.value.at.bind(this.value);
71
+ }
72
+ get concat() {
73
+ return this.value.concat.bind(this.value);
74
+ }
75
+ get flat() {
76
+ return this.value.flat.bind(this.value);
77
+ }
78
+ get splice() {
79
+ return this.value.splice.bind(this.value);
80
+ }
81
+ get flatMap() {
82
+ return this.value.flatMap.bind(this.value);
83
+ }
84
+ get push() {
85
+ return this.value.push.bind(this.value);
86
+ }
87
+ get pop() {
88
+ return this.value.pop.bind(this.value);
89
+ }
90
+ get sort() {
91
+ return this.value.sort.bind(this.value);
92
+ }
93
+ get slice() {
94
+ return this.value.slice.bind(this.value);
95
+ }
96
+ get length() {
97
+ return this.value.length;
98
+ }
99
+ get fill() {
100
+ return this.value.fill.bind(this.value);
101
+ }
102
+ get copyWithin() {
103
+ return this.value.copyWithin.bind(this.value);
104
+ }
105
+ get reverse() {
106
+ return this.value.reverse.bind(this.value);
107
+ }
108
+ get shift() {
109
+ return this.value.shift.bind(this.value);
110
+ }
111
+ get unshift() {
112
+ return this.value.unshift.bind(this.value);
113
+ }
114
+ }
115
+ return $Multiple;
116
+ };
117
+
118
+ //#endregion
119
+ exports.Multiple = Multiple;
@@ -0,0 +1,119 @@
1
+ import { Empty, Shape } from "./_.mjs";
2
+
3
+ //#region src/multiple.ts
4
+ const Multiple = (of, base = Empty) => {
5
+ const longhand = Shape(of);
6
+ class $Multiple extends base {
7
+ constructor(value) {
8
+ super();
9
+ this.value = value;
10
+ }
11
+ static $shape = "multiple";
12
+ serialize() {
13
+ return $Multiple.$serialize(this.value);
14
+ }
15
+ static deserialize(value) {
16
+ return new this($Multiple.$deserialize(value));
17
+ }
18
+ static $deserialize(value) {
19
+ return value.map(longhand.$deserialize);
20
+ }
21
+ static $serialize(value) {
22
+ return value.map(longhand.$serialize);
23
+ }
24
+ [Symbol.iterator]() {
25
+ return this.value[Symbol.iterator]();
26
+ }
27
+ get map() {
28
+ return this.value.map.bind(this.value);
29
+ }
30
+ get reduce() {
31
+ return this.value.reduce.bind(this.value);
32
+ }
33
+ get filter() {
34
+ return this.value.filter.bind(this.value);
35
+ }
36
+ get forEach() {
37
+ return this.value.forEach.bind(this.value);
38
+ }
39
+ get some() {
40
+ return this.value.some.bind(this.value);
41
+ }
42
+ get every() {
43
+ return this.value.every.bind(this.value);
44
+ }
45
+ get find() {
46
+ return this.value.find.bind(this.value);
47
+ }
48
+ get findIndex() {
49
+ return this.value.findIndex.bind(this.value);
50
+ }
51
+ get indexOf() {
52
+ return this.value.indexOf.bind(this.value);
53
+ }
54
+ get lastIndexOf() {
55
+ return this.value.lastIndexOf.bind(this.value);
56
+ }
57
+ get includes() {
58
+ return this.value.includes.bind(this.value);
59
+ }
60
+ get keys() {
61
+ return this.value.keys.bind(this.value);
62
+ }
63
+ get values() {
64
+ return this.value.values.bind(this.value);
65
+ }
66
+ get entries() {
67
+ return this.value.entries.bind(this.value);
68
+ }
69
+ get at() {
70
+ return this.value.at.bind(this.value);
71
+ }
72
+ get concat() {
73
+ return this.value.concat.bind(this.value);
74
+ }
75
+ get flat() {
76
+ return this.value.flat.bind(this.value);
77
+ }
78
+ get splice() {
79
+ return this.value.splice.bind(this.value);
80
+ }
81
+ get flatMap() {
82
+ return this.value.flatMap.bind(this.value);
83
+ }
84
+ get push() {
85
+ return this.value.push.bind(this.value);
86
+ }
87
+ get pop() {
88
+ return this.value.pop.bind(this.value);
89
+ }
90
+ get sort() {
91
+ return this.value.sort.bind(this.value);
92
+ }
93
+ get slice() {
94
+ return this.value.slice.bind(this.value);
95
+ }
96
+ get length() {
97
+ return this.value.length;
98
+ }
99
+ get fill() {
100
+ return this.value.fill.bind(this.value);
101
+ }
102
+ get copyWithin() {
103
+ return this.value.copyWithin.bind(this.value);
104
+ }
105
+ get reverse() {
106
+ return this.value.reverse.bind(this.value);
107
+ }
108
+ get shift() {
109
+ return this.value.shift.bind(this.value);
110
+ }
111
+ get unshift() {
112
+ return this.value.unshift.bind(this.value);
113
+ }
114
+ }
115
+ return $Multiple;
116
+ };
117
+
118
+ //#endregion
119
+ export { Multiple };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=multiple.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiple.spec.d.ts","sourceRoot":"","sources":["../src/multiple.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { type AbstractConstructor, type Constructor, Empty } from "./_";
2
+ export type NothingShorthand = undefined;
3
+ export declare const Nothing: <B extends AbstractConstructor<{}> = typeof Empty>(config: void, base?: B) => Omit<B, "prototype"> & Omit<(abstract new (...args: any[]) => {
4
+ serialize(): void;
5
+ }) & {
6
+ $shape: "nothing";
7
+ deserialize<T extends Constructor>(this: T, value: void): InstanceType<T>;
8
+ $deserialize(): void;
9
+ $serialize(): void;
10
+ $inline: void;
11
+ }, ""> & (abstract new (value: void) => InstanceType<B> & {
12
+ serialize(): void;
13
+ });
14
+ //# sourceMappingURL=nothing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nothing.d.ts","sourceRoot":"","sources":["../src/nothing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,WAAW,EAAmB,KAAK,EAAE,MAAM,KAAK,CAAC;AAEzF,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAEzC,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,mBAAmB,CAAC,EAAE,CAAC,yBAC/C,IAAI,SACN,CAAC;;;YAGW,SAAS;gBAGN,CAAC,SAAS,WAAW,QAChC,CAAC,SACA,IAAI,GACV,YAAY,CAAC,CAAC,CAAC;;;aAKF,IAAI;+BAIb,IAAI,KACR,YAAY,CAAC,CAAC,CAAC;;CAAW,CAOhC,CAAC"}
@@ -0,0 +1,19 @@
1
+ const require__ = require('./_.js');
2
+
3
+ //#region src/nothing.ts
4
+ const Nothing = (config, base = require__.Empty) => {
5
+ class $Nothing extends base {
6
+ static $shape = "nothing";
7
+ serialize() {}
8
+ static deserialize(value) {
9
+ return new this();
10
+ }
11
+ static $deserialize() {}
12
+ static $serialize() {}
13
+ static $inline;
14
+ }
15
+ return $Nothing;
16
+ };
17
+
18
+ //#endregion
19
+ exports.Nothing = Nothing;
@@ -0,0 +1,19 @@
1
+ import { Empty } from "./_.mjs";
2
+
3
+ //#region src/nothing.ts
4
+ const Nothing = (config, base = Empty) => {
5
+ class $Nothing extends base {
6
+ static $shape = "nothing";
7
+ serialize() {}
8
+ static deserialize(value) {
9
+ return new this();
10
+ }
11
+ static $deserialize() {}
12
+ static $serialize() {}
13
+ static $inline;
14
+ }
15
+ return $Nothing;
16
+ };
17
+
18
+ //#endregion
19
+ export { Nothing };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=nothing.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nothing.spec.d.ts","sourceRoot":"","sources":["../src/nothing.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { type Definition, type Expand, type Shorthand, type DefinitionOf, type Constructor, type AbstractConstructor, Empty } from "./_";
2
+ export type OptionalConfiguration = Definition | Shorthand;
3
+ type Matcher<V> = {
4
+ some: (value: V) => any;
5
+ none: () => any;
6
+ };
7
+ type Internal<S extends Definition | Shorthand> = {
8
+ Serialized: ReturnType<DefinitionOf<S>["$serialize"]> | undefined;
9
+ Deserializing: Parameters<DefinitionOf<S>["$deserialize"]>[0] | undefined;
10
+ Inline: Expand<DefinitionOf<S>["$inline"]> | undefined;
11
+ Required: Expand<DefinitionOf<S>["$inline"]>;
12
+ };
13
+ export declare const Optional: <S extends Definition | Shorthand, B extends AbstractConstructor<{}> = typeof Empty>(of: S, base?: B) => IOptional<S, B>;
14
+ export type IOptional<S extends Definition | Shorthand, B extends AbstractConstructor<{}> = typeof Object> = Omit<B, "prototype"> & {
15
+ $shape: "optional";
16
+ deserialize<T extends Constructor>(this: T, value: Internal<S>["Deserializing"]): InstanceType<T>;
17
+ $deserialize(value: Internal<S>["Deserializing"]): Definition["$inline"];
18
+ $serialize<T>(this: T, value: Internal<S>["Inline"]): Internal<S>["Serialized"];
19
+ $inline: Internal<S>["Inline"];
20
+ } & (abstract new (value: Internal<S>["Inline"]) => InstanceType<B> & {
21
+ value: Internal<S>["Inline"];
22
+ serialize(): Expand<Internal<S>["Serialized"]>;
23
+ match<M extends Matcher<Expand<Internal<S>["Required"]>>>(config: M): ReturnType<M["some"]> | ReturnType<M["none"]>;
24
+ });
25
+ export {};
26
+ //# sourceMappingURL=optional.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../src/optional.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,EACN,MAAM,KAAK,CAAC;AAEb,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,SAAS,CAAC;AAE3D,K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CAAC,SAAS,CAAC,CAAC;IACzE,UAAU,CAAC,CAAC,EACV,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAC3B,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAC7B,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CAChC,GAAG,CAAC,QAAQ,MACT,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KACzB,YAAY,CAAC,CAAC,CAAC,GAAG;IACrB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC7B,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/C,KAAK,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EACtD,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;CAClD,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ const require__ = require('./_.js');
2
+
3
+ //#region src/optional.ts
4
+ const Optional = (of, base = require__.Empty) => {
5
+ class $Optional extends base {
6
+ constructor(value) {
7
+ super();
8
+ this.value = value;
9
+ }
10
+ static $shape = "optional";
11
+ serialize() {
12
+ return $Optional.$serialize(this.value);
13
+ }
14
+ match(config) {
15
+ if (this.value === void 0) return config.none();
16
+ return config.some(this.value);
17
+ }
18
+ static deserialize(value) {
19
+ return new this(this.$deserialize(value));
20
+ }
21
+ static $deserialize(value) {
22
+ if (value === void 0) return;
23
+ return require__.Shape(of).$deserialize(value);
24
+ }
25
+ static $serialize(value) {
26
+ return value === void 0 ? void 0 : require__.Shape(of).$serialize(value);
27
+ }
28
+ static $inline;
29
+ }
30
+ return $Optional;
31
+ };
32
+
33
+ //#endregion
34
+ exports.Optional = Optional;
@@ -0,0 +1,34 @@
1
+ import { Empty, Shape } from "./_.mjs";
2
+
3
+ //#region src/optional.ts
4
+ const Optional = (of, base = Empty) => {
5
+ class $Optional extends base {
6
+ constructor(value) {
7
+ super();
8
+ this.value = value;
9
+ }
10
+ static $shape = "optional";
11
+ serialize() {
12
+ return $Optional.$serialize(this.value);
13
+ }
14
+ match(config) {
15
+ if (this.value === void 0) return config.none();
16
+ return config.some(this.value);
17
+ }
18
+ static deserialize(value) {
19
+ return new this(this.$deserialize(value));
20
+ }
21
+ static $deserialize(value) {
22
+ if (value === void 0) return;
23
+ return Shape(of).$deserialize(value);
24
+ }
25
+ static $serialize(value) {
26
+ return value === void 0 ? void 0 : Shape(of).$serialize(value);
27
+ }
28
+ static $inline;
29
+ }
30
+ return $Optional;
31
+ };
32
+
33
+ //#endregion
34
+ export { Optional };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=optional.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional.spec.d.ts","sourceRoot":"","sources":["../src/optional.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import { type AbstractConstructor, type Constructor, Empty, type Expand } from "./_";
2
+ type PrimitiveMap = [
3
+ [
4
+ StringConstructor,
5
+ string
6
+ ],
7
+ [
8
+ NumberConstructor,
9
+ number
10
+ ],
11
+ [
12
+ DateConstructor,
13
+ Date
14
+ ],
15
+ [
16
+ BooleanConstructor,
17
+ boolean
18
+ ]
19
+ ];
20
+ type PrimitiveConstructor = PrimitiveMap[number][0];
21
+ export type PrimitiveFromConstructor<S> = Extract<PrimitiveMap[number], [
22
+ S,
23
+ any
24
+ ]>[1];
25
+ export type PrimitiveShorthand = PrimitiveConstructor;
26
+ export type IPrimitive<S extends PrimitiveConstructor, B extends AbstractConstructor<{}> = typeof Empty> = Omit<B, ""> & (abstract new (value: Expand<PrimitiveFromConstructor<S>>) => InstanceType<B> & {
27
+ readonly value: Expand<PrimitiveFromConstructor<S>>;
28
+ serialize(): PrimitiveFromConstructor<S>;
29
+ }) & {
30
+ $shape: "primitive";
31
+ deserialize<T extends Constructor<any>>(this: T, value: PrimitiveFromConstructor<S>): InstanceType<T>;
32
+ $serialize(value: PrimitiveFromConstructor<S>): PrimitiveFromConstructor<S>;
33
+ $deserialize(value: PrimitiveFromConstructor<S>): PrimitiveFromConstructor<S>;
34
+ $inline: Expand<PrimitiveFromConstructor<S>>;
35
+ };
36
+ export declare const Primitive: <S extends PrimitiveConstructor, B extends AbstractConstructor<{}> = typeof Empty>(of: S, base?: B) => IPrimitive<S, B>;
37
+ export {};
38
+ //# sourceMappingURL=primitive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../src/primitive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAiB,KAAK,WAAW,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,CAAC;AAEpG,KAAK,YAAY,GAAG;IAClB;QAAC,iBAAiB;QAAE,MAAM;KAAC;IAC3B;QAAC,iBAAiB;QAAE,MAAM;KAAC;IAC3B;QAAC,eAAe;QAAE,IAAI;KAAC;IACvB;QAAC,kBAAkB;QAAE,OAAO;KAAC;CAC9B,CAAC;AAEF,KAAK,oBAAoB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,OAAO,CAC/C,YAAY,CAAC,MAAM,CAAC,EACpB;IAAC,CAAC;IAAE,GAAG;CAAC,CACT,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEtD,MAAM,MAAM,UAAU,CACpB,CAAC,SAAS,oBAAoB,EAC9B,CAAC,SAAS,mBAAmB,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