schematox 1.2.3 → 1.2.4-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/struct.ts +21 -11
package/package.json
CHANGED
package/src/struct.ts
CHANGED
|
@@ -115,19 +115,29 @@ export function object<T extends Record<string, StructShape<Schema>>>(of: T) {
|
|
|
115
115
|
return makeStruct(schema)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
export function record<T extends StructShape<Schema>>(
|
|
119
|
+
of: T,
|
|
120
|
+
key?: undefined
|
|
121
|
+
): Struct<{ type: 'record'; of: T['__schema'] }>
|
|
122
|
+
|
|
118
123
|
export function record<
|
|
119
124
|
T extends StructShape<Schema>,
|
|
120
|
-
U extends StructShape<StringSchema
|
|
121
|
-
>(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
U extends StructShape<StringSchema>,
|
|
126
|
+
>(
|
|
127
|
+
of: T,
|
|
128
|
+
key: U
|
|
129
|
+
): Struct<{ type: 'record'; of: T['__schema']; key: U['__schema'] }>
|
|
130
|
+
|
|
131
|
+
export function record(of: StructShape<any>, key?: StructShape<any>) {
|
|
132
|
+
if (key !== undefined) {
|
|
133
|
+
return makeStruct({
|
|
134
|
+
type: 'record',
|
|
135
|
+
of: of.__schema,
|
|
136
|
+
key: key.__schema,
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return makeStruct({ type: 'record', of: of.__schema })
|
|
131
141
|
}
|
|
132
142
|
|
|
133
143
|
export function tuple<
|