Skip to content

Commit b673fbd

Browse files
committed
feat: export all exports in module and fix collection doc
1 parent 5dce0f0 commit b673fbd

File tree

2 files changed

+1024
-7
lines changed

2 files changed

+1024
-7
lines changed

as/mod.ts

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,109 @@
1-
import { asOptional, asUnoptional } from "./optional.ts";
2-
import { asReadonly, asUnreadonly } from "./readonly.ts";
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+
export * from "./optional.ts";
8+
export * from "./readonly.ts";
39

410
/**
5-
* Annotation collection for object predicate properties.
11+
* An object containing all the functions in as module.
612
*/
7-
export const as = {
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 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} = 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 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 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 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+
} = {
8107
Optional: asOptional,
9108
Readonly: asReadonly,
10109
Unoptional: asUnoptional,

0 commit comments

Comments
 (0)