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.
- package/README.md +124 -21
- package/dist/{Either-DgkP4DUw.d.ts → Either-D4P39LPj.d.ts} +244 -54
- package/dist/chunk-7VZBQDNM.mjs +43 -0
- package/dist/chunk-7VZBQDNM.mjs.map +1 -0
- package/dist/do/index.d.ts +240 -0
- package/dist/do/index.mjs +2 -0
- package/dist/do/index.mjs.map +1 -0
- package/dist/either/index.d.ts +2 -2
- package/dist/either/index.mjs +1 -1
- package/dist/fpromise/index.d.ts +2 -2
- package/dist/fpromise/index.mjs +1 -1
- package/dist/index.d.ts +177 -151
- package/dist/index.mjs +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.mjs +1 -1
- package/dist/map/index.d.ts +2 -2
- package/dist/map/index.mjs +1 -1
- package/dist/option/index.d.ts +2 -2
- package/dist/option/index.mjs +1 -1
- package/dist/set/index.d.ts +2 -2
- package/dist/set/index.mjs +1 -1
- package/dist/try/index.d.ts +2 -74
- package/dist/try/index.mjs +1 -1
- package/dist/tuple/index.d.ts +1 -1
- package/package.json +13 -7
- package/dist/chunk-PPFDDUSD.mjs +0 -43
- package/dist/chunk-PPFDDUSD.mjs.map +0 -1
- package/dist/{Serializable-CK9upOU0.d.ts → Typeable-CitTP1ay.d.ts} +42 -42
|
@@ -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 };
|