@ddd-ts/shape 0.0.0-compute-timeout-on-process.5 → 0.0.0-compute-timeout-on-process.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"optional.js","names":[],"sources":["../src/optional.ts"],"sourcesContent":["import {\n Definition,\n Expand,\n Shorthand,\n DefinitionOf,\n Shape,\n Constructor,\n AbstractConstructor,\n Empty,\n} from \"./_\";\n\nexport type OptionalConfiguration = Definition | Shorthand;\n\ntype Matcher<V> = { some: (value: V) => any; none: () => any };\n\ntype Internal<S extends Definition | Shorthand> = {\n Serialized: ReturnType<DefinitionOf<S>[\"$serialize\"]> | undefined;\n Deserializing: Parameters<DefinitionOf<S>[\"$deserialize\"]>[0] | undefined;\n Inline: Expand<DefinitionOf<S>[\"$inline\"]> | undefined;\n Required: Expand<DefinitionOf<S>[\"$inline\"]>;\n};\n\nexport const Optional = <\n S extends Definition | Shorthand,\n B extends AbstractConstructor<{}> = typeof Empty,\n>(\n of: S,\n base: B = Empty as any,\n): IOptional<S, B> => {\n abstract class $Optional extends (base as any as Constructor<{}>) {\n constructor(public value: any) {\n super();\n }\n\n static $shape = \"optional\" as const;\n\n serialize() {\n return $Optional.$serialize((this as any).value) as any;\n }\n\n match(config: any) {\n if ((this as any).value === undefined) {\n return config.none();\n }\n return config.some((this as any).value);\n }\n\n static deserialize<T extends Constructor>(\n this: T,\n value: any,\n ): InstanceType<T> {\n return new (this as any)((this as any).$deserialize(value)) as any;\n }\n\n static $deserialize(value: any): any {\n if (value === undefined) {\n return undefined;\n }\n return (Shape(of) as any).$deserialize(value);\n }\n\n static $serialize<T extends typeof $Optional>(this: T, value: any): any {\n return value === undefined\n ? undefined\n : (Shape(of) as any).$serialize(value);\n }\n\n static $inline: any;\n }\n\n return $Optional as any;\n};\n\nexport type IOptional<\n S extends Definition | Shorthand,\n B extends AbstractConstructor<{}> = typeof Object,\n> = Omit<B, \"prototype\"> & {\n $shape: \"optional\";\n deserialize<T extends Constructor>(\n this: T,\n value: Internal<S>[\"Deserializing\"],\n ): InstanceType<T>;\n $deserialize(value: Internal<S>[\"Deserializing\"]): Definition[\"$inline\"];\n $serialize<T>(\n this: T,\n value: Internal<S>[\"Inline\"],\n ): Internal<S>[\"Serialized\"];\n $inline: Internal<S>[\"Inline\"];\n} & (abstract new (\n value: Internal<S>[\"Inline\"],\n ) => InstanceType<B> & {\n value: Internal<S>[\"Inline\"];\n serialize(): Expand<Internal<S>[\"Serialized\"]>;\n match<M extends Matcher<Expand<Internal<S>[\"Required\"]>>>(\n config: M,\n ): ReturnType<M[\"some\"]> | ReturnType<M[\"none\"]>;\n });\n"],"mappings":";;;AAsBA,MAAa,YAIX,IACA,OAAU,UACU;CACpB,MAAe,kBAAmB,KAAgC;EAChE,YAAY,AAAO,OAAY;AAC7B,UAAO;GADU;;EAInB,OAAO,SAAS;EAEhB,YAAY;AACV,UAAO,UAAU,WAAY,KAAa,MAAM;;EAGlD,MAAM,QAAa;AACjB,OAAK,KAAa,UAAU,OAC1B,QAAO,OAAO,MAAM;AAEtB,UAAO,OAAO,KAAM,KAAa,MAAM;;EAGzC,OAAO,YAEL,OACiB;AACjB,UAAO,IAAK,KAAc,KAAa,aAAa,MAAM,CAAC;;EAG7D,OAAO,aAAa,OAAiB;AACnC,OAAI,UAAU,OACZ;AAEF,UAAQ,MAAM,GAAG,CAAS,aAAa,MAAM;;EAG/C,OAAO,WAAgD,OAAiB;AACtE,UAAO,UAAU,SACb,SACC,MAAM,GAAG,CAAS,WAAW,MAAM;;EAG1C,OAAO;;AAGT,QAAO"}
1
+ {"version":3,"file":"optional.js","names":[],"sources":["../src/optional.ts"],"sourcesContent":["import {\n type Definition,\n type Expand,\n type Shorthand,\n type DefinitionOf,\n Shape,\n type Constructor,\n type AbstractConstructor,\n Empty,\n} from \"./_\";\n\nexport type OptionalConfiguration = Definition | Shorthand;\n\ntype Matcher<V> = { some: (value: V) => any; none: () => any };\n\ntype Internal<S extends Definition | Shorthand> = {\n Serialized: ReturnType<DefinitionOf<S>[\"$serialize\"]> | undefined;\n Deserializing: Parameters<DefinitionOf<S>[\"$deserialize\"]>[0] | undefined;\n Inline: Expand<DefinitionOf<S>[\"$inline\"]> | undefined;\n Required: Expand<DefinitionOf<S>[\"$inline\"]>;\n};\n\nexport const Optional = <\n S extends Definition | Shorthand,\n B extends AbstractConstructor<{}> = typeof Empty,\n>(\n of: S,\n base: B = Empty as any,\n): IOptional<S, B> => {\n abstract class $Optional extends (base as any as Constructor<{}>) {\n constructor(public value: any) {\n super();\n }\n\n static $shape = \"optional\" as const;\n\n serialize() {\n return $Optional.$serialize((this as any).value) as any;\n }\n\n match(config: any) {\n if ((this as any).value === undefined) {\n return config.none();\n }\n return config.some((this as any).value);\n }\n\n static deserialize<T extends Constructor>(\n this: T,\n value: any,\n ): InstanceType<T> {\n return new (this as any)((this as any).$deserialize(value)) as any;\n }\n\n static $deserialize(value: any): any {\n if (value === undefined) {\n return undefined;\n }\n return (Shape(of) as any).$deserialize(value);\n }\n\n static $serialize<T extends typeof $Optional>(this: T, value: any): any {\n return value === undefined\n ? undefined\n : (Shape(of) as any).$serialize(value);\n }\n\n static $inline: any;\n }\n\n return $Optional as any;\n};\n\nexport type IOptional<\n S extends Definition | Shorthand,\n B extends AbstractConstructor<{}> = typeof Object,\n> = Omit<B, \"prototype\"> & {\n $shape: \"optional\";\n deserialize<T extends Constructor>(\n this: T,\n value: Internal<S>[\"Deserializing\"],\n ): InstanceType<T>;\n $deserialize(value: Internal<S>[\"Deserializing\"]): Definition[\"$inline\"];\n $serialize<T>(\n this: T,\n value: Internal<S>[\"Inline\"],\n ): Internal<S>[\"Serialized\"];\n $inline: Internal<S>[\"Inline\"];\n} & (abstract new (\n value: Internal<S>[\"Inline\"],\n ) => InstanceType<B> & {\n value: Internal<S>[\"Inline\"];\n serialize(): Expand<Internal<S>[\"Serialized\"]>;\n match<M extends Matcher<Expand<Internal<S>[\"Required\"]>>>(\n config: M,\n ): ReturnType<M[\"some\"]> | ReturnType<M[\"none\"]>;\n });\n"],"mappings":";;;AAsBA,MAAa,YAIX,IACA,OAAU,UACU;CACpB,MAAe,kBAAmB,KAAgC;EAChE,YAAY,AAAO,OAAY;AAC7B,UAAO;GADU;;EAInB,OAAO,SAAS;EAEhB,YAAY;AACV,UAAO,UAAU,WAAY,KAAa,MAAM;;EAGlD,MAAM,QAAa;AACjB,OAAK,KAAa,UAAU,OAC1B,QAAO,OAAO,MAAM;AAEtB,UAAO,OAAO,KAAM,KAAa,MAAM;;EAGzC,OAAO,YAEL,OACiB;AACjB,UAAO,IAAK,KAAc,KAAa,aAAa,MAAM,CAAC;;EAG7D,OAAO,aAAa,OAAiB;AACnC,OAAI,UAAU,OACZ;AAEF,UAAQ,MAAM,GAAG,CAAS,aAAa,MAAM;;EAG/C,OAAO,WAAgD,OAAiB;AACtE,UAAO,UAAU,SACb,SACC,MAAM,GAAG,CAAS,WAAW,MAAM;;EAG1C,OAAO;;AAGT,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts/shape",
3
- "version": "0.0.0-compute-timeout-on-process.5",
3
+ "version": "0.0.0-compute-timeout-on-process.6",
4
4
  "types": "dist/index.d.ts",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,11 +10,11 @@
10
10
  "dist"
11
11
  ],
12
12
  "dependencies": {
13
- "@ddd-ts/traits": "0.0.0-compute-timeout-on-process.5"
13
+ "@ddd-ts/traits": "0.0.0-compute-timeout-on-process.6"
14
14
  },
15
15
  "devDependencies": {
16
- "@ddd-ts/tools": "0.0.0-compute-timeout-on-process.5",
17
- "@ddd-ts/types": "0.0.0-compute-timeout-on-process.5",
16
+ "@ddd-ts/tools": "0.0.0-compute-timeout-on-process.6",
17
+ "@ddd-ts/types": "0.0.0-compute-timeout-on-process.6",
18
18
  "@types/jest": "^29.5.1"
19
19
  },
20
20
  "exports": {