|
1 | 1 | // NOTE: This file is generated by gen-mod.ts |
2 | | -import { asOptional } from "./optional.ts"; |
3 | | -import { asReadonly } from "./readonly.ts"; |
4 | | -import { asUnoptional } from "./optional.ts"; |
5 | | -import { asUnreadonly } from "./readonly.ts"; |
6 | | - |
7 | 2 | export * from "./optional.ts"; |
8 | 3 | export * from "./readonly.ts"; |
9 | | - |
10 | | -/** |
11 | | - * An object containing all the functions in as module. |
12 | | - */ |
13 | | -export const as: { |
14 | | - /** |
15 | | - * Annotate the given predicate function as optional. |
16 | | - * |
17 | | - * Use this function to annotate a predicate function of `predObj` in {@linkcode [is/object-of].isObjectOf|isObjectOf}. |
18 | | - * |
19 | | - * Note that the annotated predicate function will return `true` if the type of `x` is `T` or `undefined`, indicating that |
20 | | - * this function is not just for annotation but it also changes the behavior of the predicate function. |
21 | | - * |
22 | | - * Use {@linkcode asUnoptional} to remove the annotation. |
23 | | - * Use {@linkcode hasOptional} to check if a predicate function has annotated with this function. |
24 | | - * |
25 | | - * To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost. |
26 | | - * |
27 | | - * ```ts |
28 | | - * import { as, is } from "@core/unknownutil"; |
29 | | - * |
30 | | - * const isMyType = is.ObjectOf({ |
31 | | - * foo: as.Optional(is.String), |
32 | | - * }); |
33 | | - * const a: unknown = {}; |
34 | | - * if (isMyType(a)) { |
35 | | - * const _: {foo?: string | undefined} = a; |
36 | | - * } |
37 | | - * ``` |
38 | | - */ |
39 | | - Optional: typeof asOptional; |
40 | | - /** |
41 | | - * Annotate the given predicate function as readonly. |
42 | | - * |
43 | | - * Use this function to annotate a predicate function of `predObj` in {@linkcode [is/object-of].isObjectOf|isObjectOf}. |
44 | | - * |
45 | | - * Use {@linkcode asUnreadonly} to remove the annotation. |
46 | | - * Use {@linkcode hasReadonly} to check if a predicate function has annotated with this function. |
47 | | - * |
48 | | - * To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost. |
49 | | - * |
50 | | - * ```ts |
51 | | - * import { as, is } from "@core/unknownutil"; |
52 | | - * |
53 | | - * const isMyType = is.ObjectOf({ |
54 | | - * foo: as.Readonly(is.String), |
55 | | - * }); |
56 | | - * const a: unknown = {}; |
57 | | - * if (isMyType(a)) { |
58 | | - * const _: {readonly foo: string} = a; |
59 | | - * } |
60 | | - * ``` |
61 | | - */ |
62 | | - Readonly: typeof asReadonly; |
63 | | - /** |
64 | | - * Unannotate the annotated predicate function with {@linkcode asOptional}. |
65 | | - * |
66 | | - * Use this function to unannotate a predicate function of `predObj` in {@linkcode [is/object-of].isObjectOf|isObjectOf}. |
67 | | - * |
68 | | - * Note that the annotated predicate function will return `true` if the type of `x` is `T`, indicating that |
69 | | - * this function is not just for annotation but it also changes the behavior of the predicate function. |
70 | | - * |
71 | | - * To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost. |
72 | | - * |
73 | | - * ```ts |
74 | | - * import { as, is } from "@core/unknownutil"; |
75 | | - * |
76 | | - * const isMyType = is.ObjectOf({ |
77 | | - * foo: as.Unoptional(as.Optional(is.String)), |
78 | | - * }); |
79 | | - * const a: unknown = {foo: "a"}; |
80 | | - * if (isMyType(a)) { |
81 | | - * const _: {foo: string} = a; |
82 | | - * } |
83 | | - * ``` |
84 | | - */ |
85 | | - Unoptional: typeof asUnoptional; |
86 | | - /** |
87 | | - * Unannotate the annotated predicate function with {@linkcode asReadonly}. |
88 | | - * |
89 | | - * Use this function to unannotate a predicate function of `predObj` in {@linkcode [is/object-of].isObjectOf|isObjectOf}. |
90 | | - * |
91 | | - * To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost. |
92 | | - * |
93 | | - * ```ts |
94 | | - * import { as, is } from "@core/unknownutil"; |
95 | | - * |
96 | | - * const isMyType = is.ObjectOf({ |
97 | | - * foo: as.Unreadonly(as.Readonly(is.String)), |
98 | | - * }); |
99 | | - * const a: unknown = {foo: "a"}; |
100 | | - * if (isMyType(a)) { |
101 | | - * const _: {foo: string} = a; |
102 | | - * } |
103 | | - * ``` |
104 | | - */ |
105 | | - Unreadonly: typeof asUnreadonly; |
106 | | -} = { |
107 | | - Optional: asOptional, |
108 | | - Readonly: asReadonly, |
109 | | - Unoptional: asUnoptional, |
110 | | - Unreadonly: asUnreadonly, |
111 | | -}; |
| 4 | +export * as as from "./as.ts"; |
0 commit comments