functype 0.11.2 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +1,3 @@
1
- type Type = unknown;
2
-
3
- /**
4
- * Base interface for objects with a type tag
5
- * @internal
6
- */
7
- interface TypeableBase<Tag extends string> {
8
- readonly _tag: Tag;
9
- }
10
- /**
11
- * Parameters for creating a Typeable instance
12
- * @internal
13
- */
14
- type TypeableParams<Tag extends string, T> = {
15
- _tag: Tag;
16
- impl: T;
17
- };
18
- /**
19
- * Utility type to extract the Tag from a Typeable type
20
- * @typeParam T - The Typeable type to extract the tag from
21
- * @internal
22
- */
23
- type ExtractTag<T> = T extends Typeable<infer Tag, unknown> ? Tag : never;
24
- type Typeable<Tag extends string, T = object> = T & TypeableBase<Tag>;
25
- /**
26
- * Core utility for creating nominal typing in TypeScript by adding a type tag to any object.
27
- * This allows for creating distinct types that are structurally identical but considered different by TypeScript's type system.
28
- *
29
- * @param params - The parameters containing the tag and implementation
30
- * @returns A Typeable object with the specified tag
31
- * @typeParam Tag - The string literal type used as the discriminator
32
- * @typeParam T - The base type to extend with the tag
33
- */
34
- declare function Typeable<Tag extends string, T>({ _tag, impl }: TypeableParams<Tag, T>): Typeable<Tag, T>;
35
- /**
36
- * Type guard with automatic type inference using the full type
37
- * @param value - The value to check
38
- * @param tag - The tag to check for
39
- * @returns Whether the value is a Typeable with the specified tag
40
- */
41
- declare function isTypeable<T>(value: unknown, tag: string): value is T;
42
-
43
1
  /**
44
2
  * Foldable type class represents data structures that can be folded to a summary value.
45
3
  *
@@ -67,6 +25,8 @@ interface Foldable<A> {
67
25
  foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
68
26
  }
69
27
 
28
+ type Type = unknown;
29
+
70
30
  /**
71
31
  * Pipe interface for functional data structures
72
32
  * @typeParam T - The type of value to pipe
@@ -93,4 +53,44 @@ interface Serializable<T> {
93
53
  serialize(): SerializationMethods<T>;
94
54
  }
95
55
 
56
+ /**
57
+ * Base interface for objects with a type tag
58
+ * @internal
59
+ */
60
+ interface TypeableBase<Tag extends string> {
61
+ readonly _tag: Tag;
62
+ }
63
+ /**
64
+ * Parameters for creating a Typeable instance
65
+ * @internal
66
+ */
67
+ type TypeableParams<Tag extends string, T> = {
68
+ _tag: Tag;
69
+ impl: T;
70
+ };
71
+ /**
72
+ * Utility type to extract the Tag from a Typeable type
73
+ * @typeParam T - The Typeable type to extract the tag from
74
+ * @internal
75
+ */
76
+ type ExtractTag<T> = T extends Typeable<infer Tag, unknown> ? Tag : never;
77
+ type Typeable<Tag extends string, T = object> = T & TypeableBase<Tag>;
78
+ /**
79
+ * Core utility for creating nominal typing in TypeScript by adding a type tag to any object.
80
+ * This allows for creating distinct types that are structurally identical but considered different by TypeScript's type system.
81
+ *
82
+ * @param params - The parameters containing the tag and implementation
83
+ * @returns A Typeable object with the specified tag
84
+ * @typeParam Tag - The string literal type used as the discriminator
85
+ * @typeParam T - The base type to extend with the tag
86
+ */
87
+ declare function Typeable<Tag extends string, T>({ _tag, impl }: TypeableParams<Tag, T>): Typeable<Tag, T>;
88
+ /**
89
+ * Type guard with automatic type inference using the full type
90
+ * @param value - The value to check
91
+ * @param tag - The tag to check for
92
+ * @returns Whether the value is a Typeable with the specified tag
93
+ */
94
+ declare function isTypeable<T>(value: unknown, tag: string): value is T;
95
+
96
96
  export { type ExtractTag as E, type Foldable as F, type Pipe as P, type Serializable as S, type Type as T, Typeable as a, type SerializationMethods as b, type TypeableParams as c, isTypeable as i };