struct-fakerator 3.1.0 → 3.3.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/config_scheme.cjs +6 -6
- package/dist/config_scheme.js +7 -7
- package/dist/create_generator_fn_async.cjs +173 -0
- package/dist/create_generator_fn_async.js +121 -0
- package/dist/index.cjs +16 -5
- package/dist/index.js +1 -0
- package/dist/types/{config_scheme.d.ts → src/config_scheme.d.ts} +6 -6
- package/dist/types/{create_config.d.ts → src/create_config.d.ts} +1 -14
- package/dist/types/src/create_generator_fn.d.ts +10 -0
- package/dist/types/src/create_generator_fn_async.d.ts +10 -0
- package/dist/types/src/create_generator_fn_async.test.d.ts +1 -0
- package/dist/types/{index.d.ts → src/index.d.ts} +1 -0
- package/dist/types/src/type.d.ts +43 -0
- package/dist/types/{utils → src/utils}/airline.d.ts +1 -1
- package/dist/types/{utils → src/utils}/commerce.d.ts +4 -0
- package/dist/types/{utils → src/utils}/common.d.ts +1 -1
- package/dist/types/{utils → src/utils}/image.d.ts +5 -0
- package/dist/types/{utils → src/utils}/index.d.ts +2 -1
- package/dist/types/{utils → src/utils}/location.d.ts +1 -1
- package/dist/types/{utils → src/utils}/string.d.ts +11 -0
- package/dist/types/{utils → src/utils}/utils.d.ts +1 -1
- package/dist/utils/commerce.cjs +5 -1
- package/dist/utils/commerce.js +2 -1
- package/dist/utils/common.cjs +2 -2
- package/dist/utils/common.js +1 -1
- package/dist/utils/image.cjs +4 -0
- package/dist/utils/image.js +2 -1
- package/dist/utils/index.cjs +18 -14
- package/dist/utils/index.js +2 -1
- package/dist/utils/string.cjs +4 -0
- package/dist/utils/string.js +2 -1
- package/dist/utils/utils.cjs +2 -2
- package/dist/utils/utils.js +1 -1
- package/package.json +53 -54
- package/dist/types/create_generator_fn.d.ts +0 -10
- package/dist/types/type.d.ts +0 -91
- /package/dist/types/{config.d.ts → src/config.d.ts} +0 -0
- /package/dist/types/{create_config.test.d.ts → src/create_config.test.d.ts} +0 -0
- /package/dist/types/{create_generator_fn.test.d.ts → src/create_generator_fn.test.d.ts} +0 -0
- /package/dist/types/{generator_fn.d.ts → src/generator_fn.d.ts} +0 -0
- /package/dist/types/{utils → src/utils}/animal.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/book.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/color.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/company.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/database.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/datatype.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/datetime.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/finance.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/food.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/git.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/hacker.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/internet.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/lorem.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/music.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/number.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/person.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/phone.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/science.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/system.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/vehicle.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/word.d.ts +0 -0
package/dist/config_scheme.cjs
CHANGED
|
@@ -33,28 +33,28 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
});
|
|
34
34
|
const external_valibot_namespaceObject = require("valibot");
|
|
35
35
|
const valueConfigScheme = external_valibot_namespaceObject.object({
|
|
36
|
-
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.
|
|
36
|
+
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.value("value", "invalid type string")),
|
|
37
37
|
generateFn: external_valibot_namespaceObject.any()
|
|
38
38
|
});
|
|
39
39
|
const selectionConfigScheme = external_valibot_namespaceObject.object({
|
|
40
|
-
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.
|
|
40
|
+
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.value("select", "invalid type string")),
|
|
41
41
|
items: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.array(external_valibot_namespaceObject.any()), external_valibot_namespaceObject.nonEmpty("items can not be empty"))
|
|
42
42
|
});
|
|
43
43
|
const arrayConfigScheme = external_valibot_namespaceObject.object({
|
|
44
|
-
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.
|
|
44
|
+
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.value("arr", "invalid type string")),
|
|
45
45
|
item: external_valibot_namespaceObject.object({}),
|
|
46
46
|
len: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.number(), external_valibot_namespaceObject.integer(), external_valibot_namespaceObject.minValue(0))
|
|
47
47
|
});
|
|
48
48
|
const tupleConfigScheme = external_valibot_namespaceObject.object({
|
|
49
|
-
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.
|
|
49
|
+
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.value("tuple", "invalid type string")),
|
|
50
50
|
configItems: external_valibot_namespaceObject.array(external_valibot_namespaceObject.any())
|
|
51
51
|
});
|
|
52
52
|
const objConfigScheme = external_valibot_namespaceObject.object({
|
|
53
|
-
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.
|
|
53
|
+
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.value("obj", "invalid type string")),
|
|
54
54
|
content: external_valibot_namespaceObject.object({})
|
|
55
55
|
});
|
|
56
56
|
const boundedSeriesScheme = external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.object({
|
|
57
|
-
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.
|
|
57
|
+
type: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.string(), external_valibot_namespaceObject.value("bounded_series", "invalid type string")),
|
|
58
58
|
upperLimit: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.number(), external_valibot_namespaceObject.minValue(0)),
|
|
59
59
|
lowerLimit: external_valibot_namespaceObject.pipe(external_valibot_namespaceObject.number(), external_valibot_namespaceObject.minValue(0)),
|
|
60
60
|
createInitValue: external_valibot_namespaceObject.any(),
|
package/dist/config_scheme.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { any, array, check, integer, minValue, nonEmpty, number, object, pipe,
|
|
1
|
+
import { any, array, check, integer, minValue, nonEmpty, number, object, pipe, string, value } from "valibot";
|
|
2
2
|
const valueConfigScheme = object({
|
|
3
|
-
type: pipe(string(),
|
|
3
|
+
type: pipe(string(), value("value", "invalid type string")),
|
|
4
4
|
generateFn: any()
|
|
5
5
|
});
|
|
6
6
|
const selectionConfigScheme = object({
|
|
7
|
-
type: pipe(string(),
|
|
7
|
+
type: pipe(string(), value("select", "invalid type string")),
|
|
8
8
|
items: pipe(array(any()), nonEmpty("items can not be empty"))
|
|
9
9
|
});
|
|
10
10
|
const arrayConfigScheme = object({
|
|
11
|
-
type: pipe(string(),
|
|
11
|
+
type: pipe(string(), value("arr", "invalid type string")),
|
|
12
12
|
item: object({}),
|
|
13
13
|
len: pipe(number(), integer(), minValue(0))
|
|
14
14
|
});
|
|
15
15
|
const tupleConfigScheme = object({
|
|
16
|
-
type: pipe(string(),
|
|
16
|
+
type: pipe(string(), value("tuple", "invalid type string")),
|
|
17
17
|
configItems: array(any())
|
|
18
18
|
});
|
|
19
19
|
const objConfigScheme = object({
|
|
20
|
-
type: pipe(string(),
|
|
20
|
+
type: pipe(string(), value("obj", "invalid type string")),
|
|
21
21
|
content: object({})
|
|
22
22
|
});
|
|
23
23
|
const boundedSeriesScheme = pipe(object({
|
|
24
|
-
type: pipe(string(),
|
|
24
|
+
type: pipe(string(), value("bounded_series", "invalid type string")),
|
|
25
25
|
upperLimit: pipe(number(), minValue(0)),
|
|
26
26
|
lowerLimit: pipe(number(), minValue(0)),
|
|
27
27
|
createInitValue: any(),
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createGeneratorByTypeAsync: ()=>createGeneratorByTypeAsync,
|
|
28
|
+
createSelectionGeneratorAsync: ()=>createSelectionGeneratorAsync,
|
|
29
|
+
createTupleGeneratorAsync: ()=>createTupleGeneratorAsync,
|
|
30
|
+
createValueGeneratorAsync: ()=>createValueGeneratorAsync,
|
|
31
|
+
createArrayGeneratorAsync: ()=>createArrayGeneratorAsync,
|
|
32
|
+
createBoundedSeriesGeneratorAsync: ()=>createBoundedSeriesGeneratorAsync,
|
|
33
|
+
createObjectGeneratorAsync: ()=>createObjectGeneratorAsync
|
|
34
|
+
});
|
|
35
|
+
const faker_namespaceObject = require("@faker-js/faker");
|
|
36
|
+
const external_valibot_namespaceObject = require("valibot");
|
|
37
|
+
const external_config_scheme_cjs_namespaceObject = require("./config_scheme.cjs");
|
|
38
|
+
const _createValueGeneratorAsync = (config, path)=>{
|
|
39
|
+
try {
|
|
40
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.valueConfigScheme, config);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
throw new Error(`config path: ${path}.value\n${err}`);
|
|
43
|
+
}
|
|
44
|
+
return ()=>Promise.resolve().then(()=>config.generateFn());
|
|
45
|
+
};
|
|
46
|
+
const createValueGeneratorAsync = (config)=>_createValueGeneratorAsync(config, "*");
|
|
47
|
+
const _createSelectionGeneratorAsync = (config, path)=>{
|
|
48
|
+
try {
|
|
49
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.selectionConfigScheme, config);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
throw new Error(`config path: ${path}.select\n${err}`);
|
|
52
|
+
}
|
|
53
|
+
const { items } = config;
|
|
54
|
+
return ()=>Promise.resolve(items[faker_namespaceObject.faker.number.int(items.length - 1)]);
|
|
55
|
+
};
|
|
56
|
+
const createSelectionGeneratorAsync = (config)=>_createSelectionGeneratorAsync(config, "*");
|
|
57
|
+
const _createObjectGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
58
|
+
try {
|
|
59
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.objConfigScheme, config);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
throw new Error(`config path: ${path}.obj\n ${err}`);
|
|
62
|
+
}
|
|
63
|
+
const keyWithFns = Object.entries(config.content).map(([key, subConfig])=>[
|
|
64
|
+
key,
|
|
65
|
+
_createGeneratorByTypeAsync(subConfig, `${path}.obj[${key}]`, customTypeMatch)
|
|
66
|
+
]);
|
|
67
|
+
return async ()=>{
|
|
68
|
+
const result = {};
|
|
69
|
+
const results = await Promise.all(keyWithFns.map(([key, generateFn])=>generateFn().then((v)=>[
|
|
70
|
+
key,
|
|
71
|
+
v
|
|
72
|
+
])));
|
|
73
|
+
for (const [key, value] of results)result[key] = value;
|
|
74
|
+
if ("transformer" in config && "function" == typeof config.transformer) return config.transformer(result);
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const createObjectGeneratorAsync = (config, customTypeMatch)=>_createObjectGeneratorAsync(config, "*", customTypeMatch);
|
|
79
|
+
const _createArrayGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
80
|
+
try {
|
|
81
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.arrayConfigScheme, config);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
throw new Error(`config path: ${path}.arr\n ${err}`);
|
|
84
|
+
}
|
|
85
|
+
const itemGeneratorFn = _createGeneratorByTypeAsync(config.item, `${path}.arr`, customTypeMatch);
|
|
86
|
+
if (config.next) {
|
|
87
|
+
const next = config.next;
|
|
88
|
+
return async ()=>{
|
|
89
|
+
let prev = await itemGeneratorFn();
|
|
90
|
+
const result = [];
|
|
91
|
+
for(let i = 0; i < config.len; i += 1){
|
|
92
|
+
const nextValue = next(prev, await itemGeneratorFn());
|
|
93
|
+
result.push(nextValue);
|
|
94
|
+
prev = nextValue;
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return ()=>Promise.all(Array.from({
|
|
100
|
+
length: config.len ?? 0
|
|
101
|
+
}, itemGeneratorFn));
|
|
102
|
+
};
|
|
103
|
+
const createArrayGeneratorAsync = (config, customTypeMatch)=>_createArrayGeneratorAsync(config, "*", customTypeMatch);
|
|
104
|
+
const _createTupleGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
105
|
+
try {
|
|
106
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.tupleConfigScheme, config);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
throw new Error(`config path: ${path}.tuple\n ${err}`);
|
|
109
|
+
}
|
|
110
|
+
const itemsFns = config.configItems.map((configItem, index)=>_createGeneratorByTypeAsync(configItem, `${path}.tuple[${index}]`, customTypeMatch));
|
|
111
|
+
return ()=>Promise.all(itemsFns.map((generateFn)=>generateFn()));
|
|
112
|
+
};
|
|
113
|
+
const createTupleGeneratorAsync = (config, customTypeMatch)=>_createTupleGeneratorAsync(config, "*", customTypeMatch);
|
|
114
|
+
const _createBoundedSeriesGeneratorAsync = (config, path)=>{
|
|
115
|
+
try {
|
|
116
|
+
external_valibot_namespaceObject.assert(external_config_scheme_cjs_namespaceObject.boundedSeriesScheme, config);
|
|
117
|
+
} catch (err) {
|
|
118
|
+
throw new Error(`config path: ${path}.boundedSeries\n ${err}`);
|
|
119
|
+
}
|
|
120
|
+
const { upperLimit, lowerLimit, createInitValue, count } = config;
|
|
121
|
+
return ()=>{
|
|
122
|
+
let value = createInitValue();
|
|
123
|
+
const boundedSeries = [];
|
|
124
|
+
for(let i = 0; i < count; i += 1){
|
|
125
|
+
value = faker_namespaceObject.faker.number.float({
|
|
126
|
+
max: upperLimit,
|
|
127
|
+
min: lowerLimit
|
|
128
|
+
}) * value;
|
|
129
|
+
boundedSeries.push(value);
|
|
130
|
+
}
|
|
131
|
+
return Promise.resolve(boundedSeries);
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const createBoundedSeriesGeneratorAsync = (config)=>_createBoundedSeriesGeneratorAsync(config, "*");
|
|
135
|
+
const _createGeneratorByTypeAsync = (config, path, customTypeMatch)=>{
|
|
136
|
+
switch(config.type){
|
|
137
|
+
case "obj":
|
|
138
|
+
return _createObjectGeneratorAsync(config, path, customTypeMatch);
|
|
139
|
+
case "arr":
|
|
140
|
+
return _createArrayGeneratorAsync(config, path, customTypeMatch);
|
|
141
|
+
case "tuple":
|
|
142
|
+
return _createTupleGeneratorAsync(config, path, customTypeMatch);
|
|
143
|
+
case "select":
|
|
144
|
+
return _createSelectionGeneratorAsync(config, path);
|
|
145
|
+
case "value":
|
|
146
|
+
return _createValueGeneratorAsync(config, path);
|
|
147
|
+
case "bounded_series":
|
|
148
|
+
return _createBoundedSeriesGeneratorAsync(config, path);
|
|
149
|
+
default:
|
|
150
|
+
if (customTypeMatch) return createValueGeneratorAsync(customTypeMatch(config, path));
|
|
151
|
+
throw new Error(`path: ${path}\nconfig type is not supported`);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const createGeneratorByTypeAsync = (config, customTypeMatch)=>_createGeneratorByTypeAsync(config, "*", customTypeMatch);
|
|
155
|
+
exports.createArrayGeneratorAsync = __webpack_exports__.createArrayGeneratorAsync;
|
|
156
|
+
exports.createBoundedSeriesGeneratorAsync = __webpack_exports__.createBoundedSeriesGeneratorAsync;
|
|
157
|
+
exports.createGeneratorByTypeAsync = __webpack_exports__.createGeneratorByTypeAsync;
|
|
158
|
+
exports.createObjectGeneratorAsync = __webpack_exports__.createObjectGeneratorAsync;
|
|
159
|
+
exports.createSelectionGeneratorAsync = __webpack_exports__.createSelectionGeneratorAsync;
|
|
160
|
+
exports.createTupleGeneratorAsync = __webpack_exports__.createTupleGeneratorAsync;
|
|
161
|
+
exports.createValueGeneratorAsync = __webpack_exports__.createValueGeneratorAsync;
|
|
162
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
163
|
+
"createArrayGeneratorAsync",
|
|
164
|
+
"createBoundedSeriesGeneratorAsync",
|
|
165
|
+
"createGeneratorByTypeAsync",
|
|
166
|
+
"createObjectGeneratorAsync",
|
|
167
|
+
"createSelectionGeneratorAsync",
|
|
168
|
+
"createTupleGeneratorAsync",
|
|
169
|
+
"createValueGeneratorAsync"
|
|
170
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
171
|
+
Object.defineProperty(exports, '__esModule', {
|
|
172
|
+
value: true
|
|
173
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { faker } from "@faker-js/faker";
|
|
2
|
+
import { assert } from "valibot";
|
|
3
|
+
import { arrayConfigScheme, boundedSeriesScheme, objConfigScheme, selectionConfigScheme, tupleConfigScheme, valueConfigScheme } from "./config_scheme.js";
|
|
4
|
+
const _createValueGeneratorAsync = (config, path)=>{
|
|
5
|
+
try {
|
|
6
|
+
assert(valueConfigScheme, config);
|
|
7
|
+
} catch (err) {
|
|
8
|
+
throw new Error(`config path: ${path}.value\n${err}`);
|
|
9
|
+
}
|
|
10
|
+
return ()=>Promise.resolve().then(()=>config.generateFn());
|
|
11
|
+
};
|
|
12
|
+
const createValueGeneratorAsync = (config)=>_createValueGeneratorAsync(config, "*");
|
|
13
|
+
const _createSelectionGeneratorAsync = (config, path)=>{
|
|
14
|
+
try {
|
|
15
|
+
assert(selectionConfigScheme, config);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
throw new Error(`config path: ${path}.select\n${err}`);
|
|
18
|
+
}
|
|
19
|
+
const { items } = config;
|
|
20
|
+
return ()=>Promise.resolve(items[faker.number.int(items.length - 1)]);
|
|
21
|
+
};
|
|
22
|
+
const createSelectionGeneratorAsync = (config)=>_createSelectionGeneratorAsync(config, "*");
|
|
23
|
+
const _createObjectGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
24
|
+
try {
|
|
25
|
+
assert(objConfigScheme, config);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
throw new Error(`config path: ${path}.obj\n ${err}`);
|
|
28
|
+
}
|
|
29
|
+
const keyWithFns = Object.entries(config.content).map(([key, subConfig])=>[
|
|
30
|
+
key,
|
|
31
|
+
_createGeneratorByTypeAsync(subConfig, `${path}.obj[${key}]`, customTypeMatch)
|
|
32
|
+
]);
|
|
33
|
+
return async ()=>{
|
|
34
|
+
const result = {};
|
|
35
|
+
const results = await Promise.all(keyWithFns.map(([key, generateFn])=>generateFn().then((v)=>[
|
|
36
|
+
key,
|
|
37
|
+
v
|
|
38
|
+
])));
|
|
39
|
+
for (const [key, value] of results)result[key] = value;
|
|
40
|
+
if ("transformer" in config && "function" == typeof config.transformer) return config.transformer(result);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const createObjectGeneratorAsync = (config, customTypeMatch)=>_createObjectGeneratorAsync(config, "*", customTypeMatch);
|
|
45
|
+
const _createArrayGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
46
|
+
try {
|
|
47
|
+
assert(arrayConfigScheme, config);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
throw new Error(`config path: ${path}.arr\n ${err}`);
|
|
50
|
+
}
|
|
51
|
+
const itemGeneratorFn = _createGeneratorByTypeAsync(config.item, `${path}.arr`, customTypeMatch);
|
|
52
|
+
if (config.next) {
|
|
53
|
+
const next = config.next;
|
|
54
|
+
return async ()=>{
|
|
55
|
+
let prev = await itemGeneratorFn();
|
|
56
|
+
const result = [];
|
|
57
|
+
for(let i = 0; i < config.len; i += 1){
|
|
58
|
+
const nextValue = next(prev, await itemGeneratorFn());
|
|
59
|
+
result.push(nextValue);
|
|
60
|
+
prev = nextValue;
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return ()=>Promise.all(Array.from({
|
|
66
|
+
length: config.len ?? 0
|
|
67
|
+
}, itemGeneratorFn));
|
|
68
|
+
};
|
|
69
|
+
const createArrayGeneratorAsync = (config, customTypeMatch)=>_createArrayGeneratorAsync(config, "*", customTypeMatch);
|
|
70
|
+
const _createTupleGeneratorAsync = (config, path, customTypeMatch)=>{
|
|
71
|
+
try {
|
|
72
|
+
assert(tupleConfigScheme, config);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
throw new Error(`config path: ${path}.tuple\n ${err}`);
|
|
75
|
+
}
|
|
76
|
+
const itemsFns = config.configItems.map((configItem, index)=>_createGeneratorByTypeAsync(configItem, `${path}.tuple[${index}]`, customTypeMatch));
|
|
77
|
+
return ()=>Promise.all(itemsFns.map((generateFn)=>generateFn()));
|
|
78
|
+
};
|
|
79
|
+
const createTupleGeneratorAsync = (config, customTypeMatch)=>_createTupleGeneratorAsync(config, "*", customTypeMatch);
|
|
80
|
+
const _createBoundedSeriesGeneratorAsync = (config, path)=>{
|
|
81
|
+
try {
|
|
82
|
+
assert(boundedSeriesScheme, config);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
throw new Error(`config path: ${path}.boundedSeries\n ${err}`);
|
|
85
|
+
}
|
|
86
|
+
const { upperLimit, lowerLimit, createInitValue, count } = config;
|
|
87
|
+
return ()=>{
|
|
88
|
+
let value = createInitValue();
|
|
89
|
+
const boundedSeries = [];
|
|
90
|
+
for(let i = 0; i < count; i += 1){
|
|
91
|
+
value = faker.number.float({
|
|
92
|
+
max: upperLimit,
|
|
93
|
+
min: lowerLimit
|
|
94
|
+
}) * value;
|
|
95
|
+
boundedSeries.push(value);
|
|
96
|
+
}
|
|
97
|
+
return Promise.resolve(boundedSeries);
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const createBoundedSeriesGeneratorAsync = (config)=>_createBoundedSeriesGeneratorAsync(config, "*");
|
|
101
|
+
const _createGeneratorByTypeAsync = (config, path, customTypeMatch)=>{
|
|
102
|
+
switch(config.type){
|
|
103
|
+
case "obj":
|
|
104
|
+
return _createObjectGeneratorAsync(config, path, customTypeMatch);
|
|
105
|
+
case "arr":
|
|
106
|
+
return _createArrayGeneratorAsync(config, path, customTypeMatch);
|
|
107
|
+
case "tuple":
|
|
108
|
+
return _createTupleGeneratorAsync(config, path, customTypeMatch);
|
|
109
|
+
case "select":
|
|
110
|
+
return _createSelectionGeneratorAsync(config, path);
|
|
111
|
+
case "value":
|
|
112
|
+
return _createValueGeneratorAsync(config, path);
|
|
113
|
+
case "bounded_series":
|
|
114
|
+
return _createBoundedSeriesGeneratorAsync(config, path);
|
|
115
|
+
default:
|
|
116
|
+
if (customTypeMatch) return createValueGeneratorAsync(customTypeMatch(config, path));
|
|
117
|
+
throw new Error(`path: ${path}\nconfig type is not supported`);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const createGeneratorByTypeAsync = (config, customTypeMatch)=>_createGeneratorByTypeAsync(config, "*", customTypeMatch);
|
|
121
|
+
export { createArrayGeneratorAsync, createBoundedSeriesGeneratorAsync, createGeneratorByTypeAsync, createObjectGeneratorAsync, createSelectionGeneratorAsync, createTupleGeneratorAsync, createValueGeneratorAsync };
|
package/dist/index.cjs
CHANGED
|
@@ -9,6 +9,9 @@ var __webpack_modules__ = {
|
|
|
9
9
|
"./create_generator_fn" (module) {
|
|
10
10
|
module.exports = require("./create_generator_fn.cjs");
|
|
11
11
|
},
|
|
12
|
+
"./create_generator_fn_async" (module) {
|
|
13
|
+
module.exports = require("./create_generator_fn_async.cjs");
|
|
14
|
+
},
|
|
12
15
|
"./generator_fn" (module) {
|
|
13
16
|
module.exports = require("./generator_fn.cjs");
|
|
14
17
|
},
|
|
@@ -61,7 +64,7 @@ var __webpack_exports__ = {};
|
|
|
61
64
|
__webpack_require__.r(__webpack_exports__);
|
|
62
65
|
__webpack_require__.d(__webpack_exports__, {
|
|
63
66
|
StructConfig: ()=>_config__rspack_import_0,
|
|
64
|
-
StructGenerator: ()=>
|
|
67
|
+
StructGenerator: ()=>_generator_fn__rspack_import_4
|
|
65
68
|
});
|
|
66
69
|
var _config__rspack_import_0 = __webpack_require__("./config");
|
|
67
70
|
var _create_config__rspack_import_1 = __webpack_require__("./create_config");
|
|
@@ -80,14 +83,22 @@ var __webpack_exports__ = {};
|
|
|
80
83
|
"StructGenerator"
|
|
81
84
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_create_generator_fn__rspack_import_2[__rspack_import_key];
|
|
82
85
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
83
|
-
var
|
|
84
|
-
var
|
|
86
|
+
var _create_generator_fn_async__rspack_import_3 = __webpack_require__("./create_generator_fn_async");
|
|
87
|
+
var __rspack_reexport = {};
|
|
88
|
+
for(const __rspack_import_key in _create_generator_fn_async__rspack_import_3)if ([
|
|
89
|
+
"default",
|
|
90
|
+
"StructConfig",
|
|
91
|
+
"StructGenerator"
|
|
92
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_create_generator_fn_async__rspack_import_3[__rspack_import_key];
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
94
|
+
var _generator_fn__rspack_import_4 = __webpack_require__("./generator_fn");
|
|
95
|
+
var _type__rspack_import_5 = __webpack_require__("./type");
|
|
85
96
|
var __rspack_reexport = {};
|
|
86
|
-
for(const __rspack_import_key in
|
|
97
|
+
for(const __rspack_import_key in _type__rspack_import_5)if ([
|
|
87
98
|
"default",
|
|
88
99
|
"StructConfig",
|
|
89
100
|
"StructGenerator"
|
|
90
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
101
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_type__rspack_import_5[__rspack_import_key];
|
|
91
102
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
92
103
|
})();
|
|
93
104
|
exports.StructConfig = __webpack_exports__.StructConfig;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./create_config.js";
|
|
2
2
|
export * from "./create_generator_fn.js";
|
|
3
|
+
export * from "./create_generator_fn_async.js";
|
|
3
4
|
export * from "./type.js";
|
|
4
5
|
import * as __rspack_external__config_js_0f05d986 from "./config.js";
|
|
5
6
|
import * as __rspack_external__generator_fn_js_1567d0d7 from "./generator_fn.js";
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
export declare const valueConfigScheme: v.ObjectSchema<{
|
|
3
|
-
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
3
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.ValueAction<string, "value", "invalid type string">]>;
|
|
4
4
|
readonly generateFn: v.AnySchema;
|
|
5
5
|
}, undefined>;
|
|
6
6
|
export declare const selectionConfigScheme: v.ObjectSchema<{
|
|
7
|
-
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
7
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.ValueAction<string, "select", "invalid type string">]>;
|
|
8
8
|
readonly items: v.SchemaWithPipe<readonly [v.ArraySchema<v.AnySchema, undefined>, v.NonEmptyAction<any[], "items can not be empty">]>;
|
|
9
9
|
}, undefined>;
|
|
10
10
|
export declare const arrayConfigScheme: v.ObjectSchema<{
|
|
11
|
-
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
11
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.ValueAction<string, "arr", "invalid type string">]>;
|
|
12
12
|
readonly item: v.ObjectSchema<{}, undefined>;
|
|
13
13
|
readonly len: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
14
14
|
}, undefined>;
|
|
15
15
|
export declare const tupleConfigScheme: v.ObjectSchema<{
|
|
16
|
-
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
16
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.ValueAction<string, "tuple", "invalid type string">]>;
|
|
17
17
|
readonly configItems: v.ArraySchema<v.AnySchema, undefined>;
|
|
18
18
|
}, undefined>;
|
|
19
19
|
export declare const objConfigScheme: v.ObjectSchema<{
|
|
20
|
-
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
20
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.ValueAction<string, "obj", "invalid type string">]>;
|
|
21
21
|
readonly content: v.ObjectSchema<{}, undefined>;
|
|
22
22
|
}, undefined>;
|
|
23
23
|
export declare const boundedSeriesScheme: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
24
|
-
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
24
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.ValueAction<string, "bounded_series", "invalid type string">]>;
|
|
25
25
|
readonly upperLimit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
26
26
|
readonly lowerLimit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
27
27
|
readonly createInitValue: v.AnySchema;
|
|
@@ -34,23 +34,10 @@ export declare const createArrayConfig: <T>(item: T, len: number, next?: (prev:
|
|
|
34
34
|
* @param {Array} configItems
|
|
35
35
|
* @return {TupleConfig}
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
<A, B, C, D, E, F, G, H, I, J>(configItems: [A, B, C, D, E, F, G, H, I, J]): TupleConfig<A, B, C, D, E, F, G, H, I, J>;
|
|
39
|
-
<A, B, C, D, E, F, G, H, I>(configItems: [A, B, C, D, E, F, G, H, I]): TupleConfig<A, B, C, D, E, F, G, H, I>;
|
|
40
|
-
<A, B, C, D, E, F, G, H>(configItems: [A, B, C, D, E, F, G, H]): TupleConfig<A, B, C, D, E, F, G, H>;
|
|
41
|
-
<A, B, C, D, E, F, G>(configItems: [A, B, C, D, E, F, G]): TupleConfig<A, B, C, D, E, F, G>;
|
|
42
|
-
<A, B, C, D, E, F>(configItems: [A, B, C, D, E, F]): TupleConfig<A, B, C, D, E, F>;
|
|
43
|
-
<A, B, C, D, E>(configItems: [A, B, C, D, E]): TupleConfig<A, B, C, D, E>;
|
|
44
|
-
<A, B, C, D>(configItems: [A, B, C, D]): TupleConfig<A, B, C, D>;
|
|
45
|
-
<A, B, C>(configItems: [A, B, C]): TupleConfig<A, B, C>;
|
|
46
|
-
<A, B>(configItems: [A, B]): TupleConfig<A, B>;
|
|
47
|
-
<A>(configItems: [A]): TupleConfig<A>;
|
|
48
|
-
}
|
|
49
|
-
export declare const createTupleConfig: CreateTupleConfig;
|
|
37
|
+
export declare const createTupleConfig: <const TItems extends readonly [unknown, ...unknown[]]>(configItems: TItems) => TupleConfig<TItems>;
|
|
50
38
|
/**
|
|
51
39
|
* bounded series
|
|
52
40
|
* @param {{ upperLimit: number, lowerLimit: number, createInitValue: () => number, count: number }} config
|
|
53
41
|
* @return {BoundedSeriesConfig}
|
|
54
42
|
*/
|
|
55
43
|
export declare const createBoundedSeriesConfig: (config: Omit<BoundedSeriesConfig, "type">) => BoundedSeriesConfig;
|
|
56
|
-
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArrayConfig, BoundedSeriesConfig, ObjectConfig, ObjectConfigWithFn, Result, SelectionConfig, TupleConfig, ValueConfig } from "./type";
|
|
2
|
+
type AllConfig = ValueConfig<unknown> | SelectionConfig<unknown> | ArrayConfig<unknown> | ObjectConfig<unknown> | ObjectConfigWithFn<unknown, unknown> | TupleConfig<readonly unknown[]> | BoundedSeriesConfig;
|
|
3
|
+
export declare const createValueGenerator: <R = unknown>(config: ValueConfig<unknown>) => (() => R);
|
|
4
|
+
export declare const createSelectionGenerator: <T extends SelectionConfig<unknown>>(config: T) => (() => Result<T>);
|
|
5
|
+
export declare const createObjectGenerator: <T extends ObjectConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
6
|
+
export declare const createArrayGenerator: <T extends ArrayConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
7
|
+
export declare const createTupleGenerator: <T extends TupleConfig<readonly unknown[]>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
8
|
+
export declare const createBoundedSeriesGenerator: <T extends BoundedSeriesConfig>(config: T) => (() => Result<T>);
|
|
9
|
+
export declare const createGeneratorByType: <T extends AllConfig>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArrayConfig, BoundedSeriesConfig, ObjectConfig, ObjectConfigWithFn, Result, SelectionConfig, TupleConfig, ValueConfig } from "./type";
|
|
2
|
+
type AllConfig = ValueConfig<unknown> | SelectionConfig<unknown> | ArrayConfig<unknown> | ObjectConfig<unknown> | ObjectConfigWithFn<unknown, unknown> | TupleConfig<readonly unknown[]> | BoundedSeriesConfig;
|
|
3
|
+
export declare const createValueGeneratorAsync: <R = unknown>(config: ValueConfig<unknown>) => (() => Promise<R>);
|
|
4
|
+
export declare const createSelectionGeneratorAsync: <T extends SelectionConfig<unknown>>(config: T) => (() => Promise<Result<T>>);
|
|
5
|
+
export declare const createObjectGeneratorAsync: <T extends ObjectConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
6
|
+
export declare const createArrayGeneratorAsync: <T extends ArrayConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
7
|
+
export declare const createTupleGeneratorAsync: <T extends TupleConfig<readonly unknown[]>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
8
|
+
export declare const createBoundedSeriesGeneratorAsync: <T extends BoundedSeriesConfig>(config: T) => (() => Promise<Result<T>>);
|
|
9
|
+
export declare const createGeneratorByTypeAsync: <T extends AllConfig>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Promise<Result<T>>);
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type ValueConfig<T> = {
|
|
2
|
+
type: "value";
|
|
3
|
+
generateFn: () => T;
|
|
4
|
+
};
|
|
5
|
+
export type SelectionConfig<T> = {
|
|
6
|
+
type: "select";
|
|
7
|
+
items: T[];
|
|
8
|
+
};
|
|
9
|
+
export type BoundedSeriesConfig = {
|
|
10
|
+
type: "bounded_series";
|
|
11
|
+
upperLimit: number;
|
|
12
|
+
lowerLimit: number;
|
|
13
|
+
createInitValue: () => number;
|
|
14
|
+
count: number;
|
|
15
|
+
};
|
|
16
|
+
export type ArrayConfig<T> = {
|
|
17
|
+
type: "arr";
|
|
18
|
+
item: T;
|
|
19
|
+
len: number;
|
|
20
|
+
next?: (prev: Result<T>, current: Result<T>) => Result<T>;
|
|
21
|
+
};
|
|
22
|
+
export type ObjectConfig<T> = {
|
|
23
|
+
type: "obj";
|
|
24
|
+
content: T;
|
|
25
|
+
};
|
|
26
|
+
export type ObjectConfigWithFn<T, R> = {
|
|
27
|
+
type: "obj";
|
|
28
|
+
content: T;
|
|
29
|
+
transformer: (v: {
|
|
30
|
+
[K in keyof T]: Result<T[K]>;
|
|
31
|
+
}) => R;
|
|
32
|
+
};
|
|
33
|
+
export type TupleConfig<TItems extends readonly unknown[]> = {
|
|
34
|
+
type: "tuple";
|
|
35
|
+
configItems: TItems;
|
|
36
|
+
};
|
|
37
|
+
type ResolveTuple<TItems extends readonly unknown[]> = {
|
|
38
|
+
[K in keyof TItems]: Result<TItems[K]>;
|
|
39
|
+
};
|
|
40
|
+
export type Result<T> = T extends ValueConfig<infer U> ? U : T extends SelectionConfig<infer S> ? S : T extends BoundedSeriesConfig ? number[] : T extends ArrayConfig<infer W> ? Array<Result<W>> : T extends ObjectConfigWithFn<infer _, infer R> ? R : T extends ObjectConfig<infer O> ? {
|
|
41
|
+
[K in keyof O]: Result<O[K]>;
|
|
42
|
+
} : T extends TupleConfig<infer TItems> ? ResolveTuple<TItems> : never;
|
|
43
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { faker } from "@faker-js/faker";
|
|
2
|
-
import type { ValueConfig } from "
|
|
2
|
+
import type { ValueConfig } from "../type";
|
|
3
3
|
/** Airline [aircraftType](https://fakerjs.dev/api/airline.html#aircraftType) */
|
|
4
4
|
export declare const aircraftType: () => ValueConfig<"narrowbody" | "regional" | "widebody">;
|
|
5
5
|
type Airline = ReturnType<typeof faker.airline.airline>;
|
|
@@ -22,3 +22,7 @@ export declare const productDescription: () => import("..").ValueConfig<string>;
|
|
|
22
22
|
export declare const productMaterial: () => import("..").ValueConfig<string>;
|
|
23
23
|
/** Commerce [productName](https://fakerjs.dev/api/commerce.html#productName) */
|
|
24
24
|
export declare const productName: () => import("..").ValueConfig<string>;
|
|
25
|
+
/** Commerce [upc](https://fakerjs.dev/api/commerce.html#upc) */
|
|
26
|
+
export declare const upc: (options?: {
|
|
27
|
+
prefix?: string;
|
|
28
|
+
} | undefined) => import("..").ValueConfig<string>;
|
|
@@ -9,6 +9,11 @@ export declare const dataUri: (options?: {
|
|
|
9
9
|
color?: string;
|
|
10
10
|
type?: "svg-uri" | "svg-base64";
|
|
11
11
|
} | undefined) => import("..").ValueConfig<string>;
|
|
12
|
+
/** Image [personPortrait](https://fakerjs.dev/api/image.html#personPortrait) */
|
|
13
|
+
export declare const personPortrait: (options?: {
|
|
14
|
+
sex?: import("@faker-js/faker").SexType;
|
|
15
|
+
size?: 512 | 256 | 128 | 64 | 32;
|
|
16
|
+
} | undefined) => import("..").ValueConfig<string>;
|
|
12
17
|
/** Image [url](https://fakerjs.dev/api/image.html#url) */
|
|
13
18
|
export declare const url: (options?: {
|
|
14
19
|
width?: number;
|
|
@@ -23,6 +23,7 @@ export * as Phone from "./phone";
|
|
|
23
23
|
export * as Science from "./science";
|
|
24
24
|
export * as String from "./string";
|
|
25
25
|
export * as System from "./system";
|
|
26
|
+
export * as Word from "./word";
|
|
27
|
+
export * as Vehicle from "./vehicle";
|
|
26
28
|
export * as utils from "./utils";
|
|
27
29
|
export { makeValueConfigFn } from "./utils";
|
|
28
|
-
export * as Vehicle from "./vehicle";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { faker } from "@faker-js/faker";
|
|
2
|
-
import type { ValueConfig } from "
|
|
2
|
+
import type { ValueConfig } from "../type";
|
|
3
3
|
/** Location [buildingNumber](https://fakerjs.dev/api/location.html#buildingNumber) */
|
|
4
4
|
export declare const buildingNumber: () => ValueConfig<string>;
|
|
5
5
|
/** Location [cardinalDirection](https://fakerjs.dev/api/location.html#cardinalDirection) */
|
|
@@ -47,6 +47,17 @@ export declare const nanoid: (length?: number | {
|
|
|
47
47
|
min: number;
|
|
48
48
|
max: number;
|
|
49
49
|
} | undefined) => import("..").ValueConfig<string>;
|
|
50
|
+
/** String [numeric](https://fakerjs.dev/api/string.html#numeric) */
|
|
51
|
+
export declare const numeric: (options?: number | {
|
|
52
|
+
length?: number | {
|
|
53
|
+
min: number;
|
|
54
|
+
max: number;
|
|
55
|
+
};
|
|
56
|
+
allowLeadingZeros?: boolean;
|
|
57
|
+
exclude?: ReadonlyArray<(string & {
|
|
58
|
+
zz_IGNORE_ME?: never;
|
|
59
|
+
}) | ("0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9")> | string;
|
|
60
|
+
} | undefined) => import("..").ValueConfig<string>;
|
|
50
61
|
/** String [octal](https://fakerjs.dev/api/string.html#octal) */
|
|
51
62
|
export declare const octal: (options?: {
|
|
52
63
|
length?: number | {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ValueConfig } from "
|
|
1
|
+
import type { ValueConfig } from "../type";
|
|
2
2
|
export declare function makeValueConfigFn<Args extends Array<unknown>, R>(fn: (...options: Args) => R): (...options: Args) => ValueConfig<R>;
|