@@ -15,9 +15,7 @@ TypeScript common types.
15
15
### Complete
16
16
17
17
``` typescript
18
- import type {
19
- CompleteType
20
- } from ' @corefunc/type/class/complete.type' ;
18
+ import type { CompleteType } from " @corefunc/type/class/complete.type" ;
21
19
interface UserInterface {
22
20
name: string ;
23
21
zip: string ;
@@ -29,10 +27,10 @@ class User implements CompleteType<UserInterface> {
29
27
}
30
28
```
31
29
30
+ ### Concrete
31
+
32
32
``` typescript
33
- import type {
34
- ConcreteType
35
- } from ' @corefunc/type/class/concrete.type' ;
33
+ import type { ConcreteType } from " @corefunc/type/class/concrete.type" ;
36
34
interface UserInterface {
37
35
email: string ;
38
36
nickname? : string ;
@@ -44,75 +42,79 @@ class User implements ConcreteType<UserInterface> {
44
42
}
45
43
```
46
44
45
+ ### Constructor
46
+
47
+ ``` typescript
48
+ import type { ConstructorType } from " @corefunc/type/class/constructor.type" ;
49
+
50
+ class ExchangeClient {}
51
+
52
+ function mixinApiPostUser<T extends ConstructorType <ExchangeClient >>(superClass : T ) {
53
+ return class extends superClass {
54
+ public postUser(data : any ) {
55
+ return this .post (` /users/ ` , data );
56
+ }
57
+ };
58
+ }
59
+
60
+ function mixinApiGetUser<T extends ConstructorType <ExchangeClient >>(superClass : T ) {
61
+ return class extends superClass {
62
+ public getUser(id : string ) {
63
+ return this .get (` /users/${id } ` );
64
+ }
65
+ };
66
+ }
67
+
68
+ class ApiClient extends mixinApiPostUser (mixinApiGetUser (ExchangeClient )) {}
69
+ ```
70
+
47
71
## Number
48
72
49
73
### Float
50
74
51
75
``` typescript
52
- import {
53
- isFloatRange , assertFloatRange
54
- } from ' @corefunc/type' ;
55
- import {
56
- TypeFloatRange , FloatRangeType , FloatRange
57
- } from ' @corefunc/type' ;
58
- const value: TypeFloatRange <0.01 , 99.99 > = 10.50 ;
76
+ import { isFloatRange , assertFloatRange } from " @corefunc/type" ;
77
+ import { TypeFloatRange , FloatRangeType , FloatRange } from " @corefunc/type" ;
78
+ const value: TypeFloatRange <0.01 , 99.99 > = 10.5 ;
59
79
```
60
80
61
81
### Integer 16
62
82
63
83
``` typescript
64
- import {
65
- isInteger16 , assertInteger16 , INT16 , INT16_MAX , INT16_MIN
66
- } from ' @corefunc/type' ;
67
- import type {
68
- TypeInteger16 , Integer16Type , Integer16
69
- } from ' @corefunc/type' ;
84
+ import { isInteger16 , assertInteger16 , INT16 , INT16_MAX , INT16_MIN } from " @corefunc/type" ;
85
+ import type { TypeInteger16 , Integer16Type , Integer16 } from " @corefunc/type" ;
70
86
const value: TypeInteger16 = 32_767 ;
71
87
```
72
88
73
89
### Integer 32
74
90
75
91
``` typescript
76
- import {
77
- isInteger32 , assertInteger32 , INT32 , INT32_MAX , INT32_MIN
78
- } from ' @corefunc/type' ;
79
- import type {
80
- TypeInteger32 , Integer32Type , Integer32
81
- } from ' @corefunc/type' ;
92
+ import { isInteger32 , assertInteger32 , INT32 , INT32_MAX , INT32_MIN } from " @corefunc/type" ;
93
+ import type { TypeInteger32 , Integer32Type , Integer32 } from " @corefunc/type" ;
82
94
const value: TypeInteger32 = 2_147_483_647 ;
83
95
```
84
96
85
97
### Integer 64
86
98
87
99
``` typescript
88
- import {
89
- isInteger64 , assertInteger64 , INT64 , INT64_MAX , INT64_MIN
90
- } from ' @corefunc/type' ;
91
- import type {
92
- TypeInteger64 , Integer64Type , Integer64
93
- } from ' @corefunc/type' ;
100
+ import { isInteger64 , assertInteger64 , INT64 , INT64_MAX , INT64_MIN } from " @corefunc/type" ;
101
+ import type { TypeInteger64 , Integer64Type , Integer64 } from " @corefunc/type" ;
94
102
const value: TypeInteger64 = 9_223_372_036_854_775_807 ;
95
103
```
96
104
97
105
### Integer Range
98
106
99
107
``` typescript
100
- import {
101
- isIntegerRange , assertIntegerRange
102
- } from ' @corefunc/type' ;
103
- import type {
104
- TypeIntegerRange , IntegerRangeType , IntegerRange
105
- } from ' @corefunc/type' ;
108
+ import { isIntegerRange , assertIntegerRange } from " @corefunc/type" ;
109
+ import type { TypeIntegerRange , IntegerRangeType , IntegerRange } from " @corefunc/type" ;
106
110
const value: TypeIntegerRange <0 , 100 > = 50 ;
107
111
```
108
112
109
113
### Numeric
110
114
111
115
``` typescript
112
- import { isNumeric , assertNumeric } from ' @corefunc/type' ;
113
- import type {
114
- TypeNumeric , NumericType , Numeric
115
- } from ' @corefunc/type' ;
116
+ import { isNumeric , assertNumeric } from " @corefunc/type" ;
117
+ import type { TypeNumeric , NumericType , Numeric } from " @corefunc/type" ;
116
118
const value: TypeNumeric <5 , 2 > = 999.99 ;
117
119
```
118
120
@@ -121,80 +123,56 @@ const value: TypeNumeric<5, 2> = 999.99;
121
123
### String Date
122
124
123
125
``` typescript
124
- import {
125
- isStringDate , assertStringDate
126
- } from ' @corefunc/type' ;
127
- import type {
128
- TypeStringDate , StringDateType , StringDate
129
- } from ' @corefunc/type' ;
126
+ import { isStringDate , assertStringDate } from " @corefunc/type" ;
127
+ import type { TypeStringDate , StringDateType , StringDate } from " @corefunc/type" ;
130
128
const value: StringDate = " 2020-01-01" ;
131
129
```
132
130
133
131
### String Fixed
134
132
135
133
``` typescript
136
- import {
137
- isStringFixed , assertStringFixed
138
- } from ' @corefunc/type' ;
139
- import type {
140
- TypeStringFixed , StringFixedType , StringFixed
141
- } from ' @corefunc/type' ;
134
+ import { isStringFixed , assertStringFixed } from " @corefunc/type" ;
135
+ import type { TypeStringFixed , StringFixedType , StringFixed } from " @corefunc/type" ;
142
136
const value: StringFixed <3 > = " USD" ;
143
137
```
144
138
145
139
### String Of Length
146
140
147
141
``` typescript
148
- import {
149
- isStringOfLength , assertStringOfLength
150
- } from ' @corefunc/type' ;
151
- import type {
152
- TypeStringOfLength , StringOfLengthType , StringOfLength
153
- } from ' @corefunc/type' ;
142
+ import { isStringOfLength , assertStringOfLength } from " @corefunc/type" ;
143
+ import type { TypeStringOfLength , StringOfLengthType , StringOfLength } from " @corefunc/type" ;
154
144
const value: StringOfLength <2 , 99 > = " Billy" ;
155
145
```
156
146
157
147
### String Time
158
148
159
149
``` typescript
160
- import {
161
- isStringTime , assertStringTime
162
- } from ' @corefunc/type' ;
163
- import type {
164
- TypeStringTime , StringTimeType , StringTime
165
- } from ' @corefunc/type' ;
150
+ import { isStringTime , assertStringTime } from " @corefunc/type" ;
151
+ import type { TypeStringTime , StringTimeType , StringTime } from " @corefunc/type" ;
166
152
const value: StringTime = " 12:59" ;
167
153
```
168
154
169
155
### String Varying
170
156
171
157
``` typescript
172
- import {
173
- isStringVarying , assertStringVarying
174
- } from ' @corefunc/type' ;
175
- import type {
176
- TypeStringVarying , StringVaryingType , StringVarying
177
- } from ' @corefunc/type' ;
158
+ import { isStringVarying , assertStringVarying } from " @corefunc/type" ;
159
+ import type { TypeStringVarying , StringVaryingType , StringVarying } from " @corefunc/type" ;
178
160
const value: StringVarying <254 > = " user+inbox@domain" ;
179
161
```
180
162
181
163
### UUID
182
164
183
165
``` typescript
184
- import { isUuid , assertUuid } from ' @corefunc/type' ;
185
- import type {
186
- TypeUUID , UUIDType , UUID
187
- } from ' @corefunc/type' ;
166
+ import { isUuid , assertUuid } from " @corefunc/type" ;
167
+ import type { TypeUUID , UUIDType , UUID } from " @corefunc/type" ;
188
168
const value: UUID = " 0b0bc0f0-db42-11eb-8d19-0242ac130003" ;
189
169
```
190
170
191
171
### UUID 4
192
172
193
173
``` typescript
194
- import { isUuid4 , assertUuid4 } from ' @corefunc/type' ;
195
- import type {
196
- TypeUUID4 , UUID4Type , UUID4
197
- } from ' @corefunc/type' ;
174
+ import { isUuid4 , assertUuid4 } from " @corefunc/type" ;
175
+ import type { TypeUUID4 , UUID4Type , UUID4 } from " @corefunc/type" ;
198
176
const value: UUID4 = " 155fbaaf-09de-4141-80df-94696eed4cb6" ;
199
177
```
200
178
0 commit comments