Skip to content

Commit e3ba2ed

Browse files
committed
tree-shakable exports
1 parent e377132 commit e3ba2ed

File tree

6 files changed

+52
-1149
lines changed

6 files changed

+52
-1149
lines changed

as/as.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// NOTE: This file is generated by gen-mod.ts
2+
export { asOptional as Optional } from "./optional.ts";
3+
export { asReadonly as Readonly } from "./readonly.ts";
4+
export { asUnoptional as Unoptional } from "./optional.ts";
5+
export { asUnreadonly as Unreadonly } from "./readonly.ts";

as/mod.ts

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,4 @@
11
// 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-
72
export * from "./optional.ts";
83
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";

deno.jsonc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
"exports": {
88
".": "./mod.ts",
99
"./as": "./as/mod.ts",
10+
"./as/as": "./as/as.ts",
1011
"./as/optional": "./as/optional.ts",
1112
"./as/readonly": "./as/readonly.ts",
1213
"./assert": "./assert.ts",
1314
"./ensure": "./ensure.ts",
1415
"./is": "./is/mod.ts",
16+
"./is/is": "./is/is.ts",
1517
"./is/any": "./is/any.ts",
1618
"./is/array": "./is/array.ts",
1719
"./is/array-of": "./is/array_of.ts",

is/is.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// NOTE: This file is generated by gen-mod.ts
2+
export { isAny as Any } from "./any.ts";
3+
export { isArray as Array } from "./array.ts";
4+
export { isArrayOf as ArrayOf } from "./array_of.ts";
5+
export { isAsyncFunction as AsyncFunction } from "./async_function.ts";
6+
export { isBigint as Bigint } from "./bigint.ts";
7+
export { isBoolean as Boolean } from "./boolean.ts";
8+
export { isCustomJsonable as CustomJsonable } from "./custom_jsonable.ts";
9+
export { isFunction as Function } from "./function.ts";
10+
export { isInstanceOf as InstanceOf } from "./instance_of.ts";
11+
export { isIntersectionOf as IntersectionOf } from "./intersection_of.ts";
12+
export { isJsonable as Jsonable } from "./jsonable.ts";
13+
export { isLiteralOf as LiteralOf } from "./literal_of.ts";
14+
export { isLiteralOneOf as LiteralOneOf } from "./literal_one_of.ts";
15+
export { isMap as Map } from "./map.ts";
16+
export { isMapOf as MapOf } from "./map_of.ts";
17+
export { isNull as Null } from "./null.ts";
18+
export { isNullish as Nullish } from "./nullish.ts";
19+
export { isNumber as Number } from "./number.ts";
20+
export { isObjectOf as ObjectOf } from "./object_of.ts";
21+
export { isOmitOf as OmitOf } from "./omit_of.ts";
22+
export { isParametersOf as ParametersOf } from "./parameters_of.ts";
23+
export { isPartialOf as PartialOf } from "./partial_of.ts";
24+
export { isPickOf as PickOf } from "./pick_of.ts";
25+
export { isPrimitive as Primitive } from "./primitive.ts";
26+
export { isReadonlyOf as ReadonlyOf } from "./readonly_of.ts";
27+
export { isRecord as Record } from "./record.ts";
28+
export { isRecordObject as RecordObject } from "./record_object.ts";
29+
export { isRecordObjectOf as RecordObjectOf } from "./record_object_of.ts";
30+
export { isRecordOf as RecordOf } from "./record_of.ts";
31+
export { isRequiredOf as RequiredOf } from "./required_of.ts";
32+
export { isSet as Set } from "./set.ts";
33+
export { isSetOf as SetOf } from "./set_of.ts";
34+
export { isStrictOf as StrictOf } from "./strict_of.ts";
35+
export { isString as String } from "./string.ts";
36+
export { isSymbol as Symbol } from "./symbol.ts";
37+
export { isSyncFunction as SyncFunction } from "./sync_function.ts";
38+
export { isTupleOf as TupleOf } from "./tuple_of.ts";
39+
export { isUndefined as Undefined } from "./undefined.ts";
40+
export { isUniformTupleOf as UniformTupleOf } from "./uniform_tuple_of.ts";
41+
export { isUnionOf as UnionOf } from "./union_of.ts";
42+
export { isUnknown as Unknown } from "./unknown.ts";

0 commit comments

Comments
 (0)