@ramiyohay/schema-faker 0.3.0 → 0.4.0
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/dist/generate.js +9 -6
- package/package.json +1 -1
package/dist/generate.js
CHANGED
|
@@ -8,11 +8,14 @@ function generate(schema, options = {}) {
|
|
|
8
8
|
const ctx = {
|
|
9
9
|
random: new random_1.Random(options.seed),
|
|
10
10
|
};
|
|
11
|
-
//
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
// Function to generate a single value
|
|
12
|
+
const makeOne = () => {
|
|
13
|
+
const value = (0, parseZod_1.parseZodSchema)(schema, ctx);
|
|
14
|
+
return options.overrides ? (0, deepMerge_1.deepMerge)(value, options.overrides) : value;
|
|
15
|
+
};
|
|
16
|
+
// Handle count option
|
|
17
|
+
if (options.count && options.count > 1) {
|
|
18
|
+
return Array.from({ length: options.count }, makeOne);
|
|
16
19
|
}
|
|
17
|
-
return
|
|
20
|
+
return makeOne();
|
|
18
21
|
}
|