@@ -8,203 +8,6 @@ TypeScript common types.
88[ ![ NPM Downloads] [ npm-downloads-img ]] [ npm-downloads-url ]
99[ ![ TypeScript Typings] [ ts-img ]] [ ts-url ]
1010
11- # Reference
12-
13- ## Class
14-
15- ### Complete
16-
17- ``` typescript
18- import type { CompleteType } from " @corefunc/type/class/complete.type" ;
19- interface UserInterface {
20- name: string ;
21- zip: string ;
22- }
23- // Forces class to implement all interface properties.
24- class User implements CompleteType <UserInterface > {
25- public name: string ;
26- public zip: string ;
27- }
28- ```
29-
30- ### Concrete
31-
32- ``` typescript
33- import type { ConcreteType } from " @corefunc/type/class/concrete.type" ;
34- interface UserInterface {
35- email: string ;
36- nickname? : string ;
37- }
38- // Disallow 'optional' properties from inherited type.
39- class User implements ConcreteType <UserInterface > {
40- email: string ;
41- nickname: string | undefined ;
42- }
43- ```
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-
71- ### Key of class
72-
73- ``` typescript
74- import { keyOfClass } from " @corefunc/type/class/key-of-class" ;
75- class User {
76- public static readonly name: string = keyOfClass <User >(" name" );
77- public readonly name: string ;
78- }
79- ```
80-
81- ## JSON
82-
83- ### JSON types
84-
85- ``` typescript
86- import type {
87- JsonPrimitiveType ,
88- JsonArrayType ,
89- JsonObjectType ,
90- JsonType ,
91- } from " @corefunc/type/json" ;
92- ```
93-
94- ## Number
95-
96- ### Float
97-
98- ``` typescript
99- import { isFloatRange , assertFloatRange } from " @corefunc/type" ;
100- import { TypeFloatRange , FloatRangeType , FloatRange } from " @corefunc/type" ;
101- const value: TypeFloatRange <0.01 , 99.99 > = 10.5 ;
102- ```
103-
104- ### Integer 16
105-
106- ``` typescript
107- import { isInteger16 , assertInteger16 , INT16 , INT16_MAX , INT16_MIN } from " @corefunc/type" ;
108- import type { TypeInteger16 , Integer16Type , Integer16 } from " @corefunc/type" ;
109- const value: TypeInteger16 = 32_767 ;
110- ```
111-
112- ### Integer 32
113-
114- ``` typescript
115- import { isInteger32 , assertInteger32 , INT32 , INT32_MAX , INT32_MIN } from " @corefunc/type" ;
116- import type { TypeInteger32 , Integer32Type , Integer32 } from " @corefunc/type" ;
117- const value: TypeInteger32 = 2_147_483_647 ;
118- ```
119-
120- ### Integer 64
121-
122- ``` typescript
123- import { isInteger64 , assertInteger64 , INT64 , INT64_MAX , INT64_MIN } from " @corefunc/type" ;
124- import type { TypeInteger64 , Integer64Type , Integer64 } from " @corefunc/type" ;
125- const value: TypeInteger64 = 9_223_372_036_854_775_807 ;
126- ```
127-
128- ### Integer Range
129-
130- ``` typescript
131- import { isIntegerRange , assertIntegerRange } from " @corefunc/type" ;
132- import type { TypeIntegerRange , IntegerRangeType , IntegerRange } from " @corefunc/type" ;
133- const value: TypeIntegerRange <0 , 100 > = 50 ;
134- ```
135-
136- ### Numeric
137-
138- ``` typescript
139- import { isNumeric , assertNumeric } from " @corefunc/type" ;
140- import type { TypeNumeric , NumericType , Numeric } from " @corefunc/type" ;
141- const value: TypeNumeric <5 , 2 > = 999.99 ;
142- ```
143-
144- ## String
145-
146- ### String Date
147-
148- ``` typescript
149- import { isStringDate , assertStringDate } from " @corefunc/type" ;
150- import type { TypeStringDate , StringDateType , StringDate } from " @corefunc/type" ;
151- const value: StringDate = " 2020-01-01" ;
152- ```
153-
154- ### String Fixed
155-
156- ``` typescript
157- import { isStringFixed , assertStringFixed } from " @corefunc/type" ;
158- import type { TypeStringFixed , StringFixedType , StringFixed } from " @corefunc/type" ;
159- const value: StringFixed <3 > = " USD" ;
160- ```
161-
162- ### String Of Length
163-
164- ``` typescript
165- import { isStringOfLength , assertStringOfLength } from " @corefunc/type" ;
166- import type { TypeStringOfLength , StringOfLengthType , StringOfLength } from " @corefunc/type" ;
167- const value: StringOfLength <2 , 99 > = " Billy" ;
168- ```
169-
170- ### String Time
171-
172- ``` typescript
173- import { isStringTime , assertStringTime } from " @corefunc/type" ;
174- import type { TypeStringTime , StringTimeType , StringTime } from " @corefunc/type" ;
175- const value: StringTime = " 12:59" ;
176- ```
177-
178- ### String Varying
179-
180- ``` typescript
181- import { isStringVarying , assertStringVarying } from " @corefunc/type" ;
182- import type { TypeStringVarying , StringVaryingType , StringVarying } from " @corefunc/type" ;
183- const value: StringVarying <254 > = " user+inbox@domain" ;
184- ```
185-
186- ### UUID
187-
188- ``` typescript
189- import { isUuid , assertUuid } from " @corefunc/type" ;
190- import type { TypeUUID , UUIDType , UUID } from " @corefunc/type" ;
191- const value: UUID = " 0b0bc0f0-db42-11eb-8d19-0242ac130003" ;
192- ```
193-
194- ### UUID 4
195-
196- ``` typescript
197- import { isUuid4 , assertUuid4 } from " @corefunc/type" ;
198- import type { TypeUUID4 , UUID4Type , UUID4 } from " @corefunc/type" ;
199- const value: UUID4 = " 155fbaaf-09de-4141-80df-94696eed4cb6" ;
200- ```
201-
202- ## See also
203-
204- [ 💾 My other projects] ( https://r37r0m0d3l.icu/open_source_map )
205-
206- <img alt =" Open Source " src =" https://raw.githubusercontent.com/r37r0m0d3l/r37r0m0d3l/master/osmap.svg?sanitize=true " width =" 960 " height =" 520 " style =" display :block ;height :auto ;margin-left :auto ;margin-right :auto ;min-height :520px ;min-width :960px ;width :100% ;" >
207-
20811<!-- Badges -->
20912
21013[ npm-version-url ] : https://npmjs.com/package/@corefunc/type
0 commit comments