struct-fakerator 1.2.4 → 1.2.6

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/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3
3
  "organizeImports": {
4
4
  "enabled": true
5
5
  },
@@ -0,0 +1,96 @@
1
+ type ValueConfig<T> = {
2
+ type: "value";
3
+ generateFn: () => T;
4
+ };
5
+
6
+ type SelectionConfig<T> = {
7
+ type: "select";
8
+ items: T[];
9
+ };
10
+
11
+ type TupleConfig = {
12
+ type: "tuple";
13
+ configItems: (
14
+ | ArrayConfig
15
+ | ObjectConfig
16
+ | TupleConfig
17
+ | BoundedSeriesConfig
18
+ | ValueConfig<unknown>
19
+ | SelectionConfig<unknown>
20
+ )[];
21
+ };
22
+
23
+ type ObjectConfig = {
24
+ type: "obj";
25
+ content: Record<
26
+ string,
27
+ | ArrayConfig
28
+ | ObjectConfig
29
+ | TupleConfig
30
+ | BoundedSeriesConfig
31
+ | ValueConfig<unknown>
32
+ | SelectionConfig<unknown>
33
+ >;
34
+ };
35
+
36
+ type ArrayConfig = {
37
+ type: "arr";
38
+ item:
39
+ | ArrayConfig
40
+ | ObjectConfig
41
+ | TupleConfig
42
+ | BoundedSeriesConfig
43
+ | ValueConfig<unknown>
44
+ | SelectionConfig<unknown>;
45
+ len: number;
46
+ };
47
+
48
+ type BoundedSeriesConfig = {
49
+ type: "bounded_series";
50
+ upperLimit: number;
51
+ lowerLimit: number;
52
+ createInitValue: () => number;
53
+ count: number;
54
+ };
55
+
56
+ declare function createValueConfig<T>(generateFn: () => T): ValueConfig<T>;
57
+
58
+ declare function createSelectionConfig<T>(items: T[]): SelectionConfig<T>;
59
+
60
+ declare function createObjectConfig(
61
+ content: Record<
62
+ string,
63
+ | ArrayConfig
64
+ | ObjectConfig
65
+ | TupleConfig
66
+ | ValueConfig<unknown>
67
+ | SelectionConfig<unknown>
68
+ >,
69
+ ): ObjectConfig;
70
+
71
+ declare function createArrayConfig(
72
+ item:
73
+ | ArrayConfig
74
+ | ObjectConfig
75
+ | TupleConfig
76
+ | ValueConfig<unknown>
77
+ | SelectionConfig<unknown>,
78
+ len: number,
79
+ ): ArrayConfig;
80
+
81
+ declare function createTupleConfig(
82
+ configItems: (
83
+ | ArrayConfig
84
+ | ObjectConfig
85
+ | TupleConfig
86
+ | ValueConfig<unknown>
87
+ | SelectionConfig<unknown>
88
+ )[],
89
+ ): TupleConfig;
90
+
91
+ declare function createBoundedSeriesConfig(config: {
92
+ upperLimit: number;
93
+ lowerLimit: number;
94
+ createInitValue: () => number;
95
+ count: number;
96
+ }): BoundedSeriesConfig;
@@ -0,0 +1,35 @@
1
+ declare function createValueGenerator<T>(config: ValueConfig<T>): () => T;
2
+
3
+ declare function createSelectionGenerator<T>(
4
+ config: SelectionConfig<T>,
5
+ ): () => T;
6
+
7
+ declare function createObjectGenerator(
8
+ config: ObjectConfig,
9
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
10
+ ): () => Record<string, unknown>;
11
+
12
+ declare function createArrayGenerator(
13
+ config: ArrayConfig,
14
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
15
+ ): () => unknown[];
16
+
17
+ declare function createTupleGenerator(
18
+ config: TupleConfig,
19
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
20
+ ): () => unknown[];
21
+
22
+ declare function createBoundedSeriesGenerator(
23
+ config: BoundedSeriesConfig,
24
+ ): () => number[];
25
+
26
+ declare function createGeneratorByType(
27
+ config:
28
+ | ValueConfig<unknown>
29
+ | SelectionConfig<unknown>
30
+ | ArrayConfig
31
+ | ObjectConfig
32
+ | TupleConfig
33
+ | BoundedSeriesConfig,
34
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
35
+ ): () => unknown;
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "struct-fakerator",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./cjs/index.js",
10
+ "import": "./esm/index.mjs"
11
+ }
12
+ },
7
13
  "type": "module",
8
14
  "scripts": {
9
15
  "start": "node src/index.js",
@@ -15,17 +21,18 @@
15
21
  },
16
22
  "keywords": [],
17
23
  "author": "FizzyElt",
24
+ "homepage": "https://github.com/FizzyElt/struct-fakerator",
18
25
  "license": "ISC",
19
26
  "devDependencies": {
20
- "@babel/cli": "^7.24.6",
21
- "@babel/core": "^7.24.6",
22
- "@babel/preset-env": "^7.24.6",
23
- "@biomejs/biome": "^1.7.1",
27
+ "@babel/cli": "^7.24.7",
28
+ "@babel/core": "^7.24.7",
29
+ "@babel/preset-env": "^7.24.7",
30
+ "@biomejs/biome": "^1.8.3",
24
31
  "@faker-js/faker": "^8.4.1",
25
- "vitest": "^1.5.2"
32
+ "vitest": "^1.6.0"
26
33
  },
27
34
  "dependencies": {
28
- "zod": "^3.23.6"
35
+ "zod": "^3.23.8"
29
36
  },
30
37
  "publishConfig": {
31
38
  "access": "public"
@@ -0,0 +1,96 @@
1
+ type ValueConfig<T> = {
2
+ type: "value";
3
+ generateFn: () => T;
4
+ };
5
+
6
+ type SelectionConfig<T> = {
7
+ type: "select";
8
+ items: T[];
9
+ };
10
+
11
+ type TupleConfig = {
12
+ type: "tuple";
13
+ configItems: (
14
+ | ArrayConfig
15
+ | ObjectConfig
16
+ | TupleConfig
17
+ | BoundedSeriesConfig
18
+ | ValueConfig<unknown>
19
+ | SelectionConfig<unknown>
20
+ )[];
21
+ };
22
+
23
+ type ObjectConfig = {
24
+ type: "obj";
25
+ content: Record<
26
+ string,
27
+ | ArrayConfig
28
+ | ObjectConfig
29
+ | TupleConfig
30
+ | BoundedSeriesConfig
31
+ | ValueConfig<unknown>
32
+ | SelectionConfig<unknown>
33
+ >;
34
+ };
35
+
36
+ type ArrayConfig = {
37
+ type: "arr";
38
+ item:
39
+ | ArrayConfig
40
+ | ObjectConfig
41
+ | TupleConfig
42
+ | BoundedSeriesConfig
43
+ | ValueConfig<unknown>
44
+ | SelectionConfig<unknown>;
45
+ len: number;
46
+ };
47
+
48
+ type BoundedSeriesConfig = {
49
+ type: "bounded_series";
50
+ upperLimit: number;
51
+ lowerLimit: number;
52
+ createInitValue: () => number;
53
+ count: number;
54
+ };
55
+
56
+ declare function createValueConfig<T>(generateFn: () => T): ValueConfig<T>;
57
+
58
+ declare function createSelectionConfig<T>(items: T[]): SelectionConfig<T>;
59
+
60
+ declare function createObjectConfig(
61
+ content: Record<
62
+ string,
63
+ | ArrayConfig
64
+ | ObjectConfig
65
+ | TupleConfig
66
+ | ValueConfig<unknown>
67
+ | SelectionConfig<unknown>
68
+ >,
69
+ ): ObjectConfig;
70
+
71
+ declare function createArrayConfig(
72
+ item:
73
+ | ArrayConfig
74
+ | ObjectConfig
75
+ | TupleConfig
76
+ | ValueConfig<unknown>
77
+ | SelectionConfig<unknown>,
78
+ len: number,
79
+ ): ArrayConfig;
80
+
81
+ declare function createTupleConfig(
82
+ configItems: (
83
+ | ArrayConfig
84
+ | ObjectConfig
85
+ | TupleConfig
86
+ | ValueConfig<unknown>
87
+ | SelectionConfig<unknown>
88
+ )[],
89
+ ): TupleConfig;
90
+
91
+ declare function createBoundedSeriesConfig(config: {
92
+ upperLimit: number;
93
+ lowerLimit: number;
94
+ createInitValue: () => number;
95
+ count: number;
96
+ }): BoundedSeriesConfig;
@@ -0,0 +1,35 @@
1
+ declare function createValueGenerator<T>(config: ValueConfig<T>): () => T;
2
+
3
+ declare function createSelectionGenerator<T>(
4
+ config: SelectionConfig<T>,
5
+ ): () => T;
6
+
7
+ declare function createObjectGenerator(
8
+ config: ObjectConfig,
9
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
10
+ ): () => Record<string, unknown>;
11
+
12
+ declare function createArrayGenerator(
13
+ config: ArrayConfig,
14
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
15
+ ): () => unknown[];
16
+
17
+ declare function createTupleGenerator(
18
+ config: TupleConfig,
19
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
20
+ ): () => unknown[];
21
+
22
+ declare function createBoundedSeriesGenerator(
23
+ config: BoundedSeriesConfig,
24
+ ): () => number[];
25
+
26
+ declare function createGeneratorByType(
27
+ config:
28
+ | ValueConfig<unknown>
29
+ | SelectionConfig<unknown>
30
+ | ArrayConfig
31
+ | ObjectConfig
32
+ | TupleConfig
33
+ | BoundedSeriesConfig,
34
+ customTypeMatch?: (config: object) => ValueConfig<unknown>,
35
+ ): () => unknown;