struct-fakerator 2.1.1 → 2.1.2
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/index.d.mts +87 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +5869 -0
- package/dist/index.mjs +5831 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
type ValueConfig<T> = {
|
|
2
|
+
type: "value";
|
|
3
|
+
generateFn: () => T;
|
|
4
|
+
};
|
|
5
|
+
type SelectionConfig<T> = {
|
|
6
|
+
type: "select";
|
|
7
|
+
items: T[];
|
|
8
|
+
};
|
|
9
|
+
type BoundedSeriesConfig = {
|
|
10
|
+
type: "bounded_series";
|
|
11
|
+
upperLimit: number;
|
|
12
|
+
lowerLimit: number;
|
|
13
|
+
createInitValue: () => number;
|
|
14
|
+
count: number;
|
|
15
|
+
};
|
|
16
|
+
type ArrayConfig<T> = {
|
|
17
|
+
type: "arr";
|
|
18
|
+
item: T;
|
|
19
|
+
len: number;
|
|
20
|
+
};
|
|
21
|
+
type ObjectConfig<T> = {
|
|
22
|
+
type: "obj";
|
|
23
|
+
content: T;
|
|
24
|
+
};
|
|
25
|
+
type TupleConfig<A, B = undefined, C = undefined, D = undefined, E = undefined> = {
|
|
26
|
+
type: "tuple";
|
|
27
|
+
configItems: E extends undefined ? D extends undefined ? C extends undefined ? B extends undefined ? [A] : [A, B] : [A, B, C] : [A, B, C, D] : [A, B, C, D, E];
|
|
28
|
+
};
|
|
29
|
+
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 ObjectConfig<infer O> ? {
|
|
30
|
+
[K in keyof O]: Result<O[K]>;
|
|
31
|
+
} : T extends TupleConfig<infer A, infer B, infer C, infer D, infer E> ? E extends undefined ? D extends undefined ? C extends undefined ? B extends undefined ? [Result<A>] : [Result<A>, Result<B>] : [Result<A>, Result<B>, Result<C>] : [Result<A>, Result<B>, Result<C>, Result<D>] : [Result<A>, Result<B>, Result<C>, Result<D>, Result<E>] : never;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* value
|
|
35
|
+
* @param {function} generateFn - The function used to generate the value.
|
|
36
|
+
* @return {ValueConfig} The configuration object with the type "value" and the provided generate function.
|
|
37
|
+
*/
|
|
38
|
+
declare const createValueConfig: <T>(generateFn: () => T) => ValueConfig<T>;
|
|
39
|
+
/**
|
|
40
|
+
* selection
|
|
41
|
+
* @param {Array} items - The array of items to choose from.
|
|
42
|
+
* @return {SelectionConfig} The configuration object with the type "select" and the provided items.
|
|
43
|
+
*/
|
|
44
|
+
declare const createSelectionConfig: <T>(items: T[]) => SelectionConfig<T>;
|
|
45
|
+
/**
|
|
46
|
+
* object
|
|
47
|
+
* @param {object} content
|
|
48
|
+
* @return {ObjectConfig}
|
|
49
|
+
*/
|
|
50
|
+
declare const createObjectConfig: <T extends object>(content: T) => ObjectConfig<T>;
|
|
51
|
+
/**
|
|
52
|
+
* array
|
|
53
|
+
* @param {object} item
|
|
54
|
+
* @param {number} len
|
|
55
|
+
* @return {ArrayConfig}
|
|
56
|
+
*/
|
|
57
|
+
declare const createArrayConfig: <T>(item: T, len: number) => ArrayConfig<T>;
|
|
58
|
+
/**
|
|
59
|
+
* tuple
|
|
60
|
+
* @param {Array} configItems
|
|
61
|
+
* @return {TupleConfig}
|
|
62
|
+
*/
|
|
63
|
+
interface CreateTupleConfig {
|
|
64
|
+
<A, B, C, D, E>(configItems: [A, B, C, D, E]): TupleConfig<A, B, C, D, E>;
|
|
65
|
+
<A, B, C, D>(configItems: [A, B, C, D]): TupleConfig<A, B, C, D>;
|
|
66
|
+
<A, B, C>(configItems: [A, B, C]): TupleConfig<A, B, C>;
|
|
67
|
+
<A, B>(configItems: [A, B]): TupleConfig<A, B>;
|
|
68
|
+
<A>(configItems: [A]): TupleConfig<A>;
|
|
69
|
+
}
|
|
70
|
+
declare const createTupleConfig: CreateTupleConfig;
|
|
71
|
+
/**
|
|
72
|
+
* bounded series
|
|
73
|
+
* @param {{ upperLimit: number, lowerLimit: number, createInitValue: () => number, count: number }} config
|
|
74
|
+
* @return {BoundedSeriesConfig}
|
|
75
|
+
*/
|
|
76
|
+
declare const createBoundedSeriesConfig: (config: Omit<BoundedSeriesConfig, "type">) => BoundedSeriesConfig;
|
|
77
|
+
|
|
78
|
+
type AllConfig<T> = ValueConfig<T> | SelectionConfig<T> | ArrayConfig<T> | ObjectConfig<T> | TupleConfig<T> | TupleConfig<T, T> | TupleConfig<T, T, T> | TupleConfig<T, T, T, T> | TupleConfig<T, T, T, T, T> | BoundedSeriesConfig;
|
|
79
|
+
declare const createValueGenerator: <R = unknown>(config: ValueConfig<unknown>) => (() => R);
|
|
80
|
+
declare const createSelectionGenerator: <T extends SelectionConfig<unknown>>(config: T) => (() => Result<T>);
|
|
81
|
+
declare const createObjectGenerator: <T extends ObjectConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
82
|
+
declare const createArrayGenerator: <T extends ArrayConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
83
|
+
declare const createTupleGenerator: <T extends TupleConfig<unknown, unknown, unknown, unknown, unknown> | TupleConfig<unknown, unknown, unknown, unknown> | TupleConfig<unknown, unknown, unknown> | TupleConfig<unknown, unknown> | TupleConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
84
|
+
declare const createBoundedSeriesGenerator: <T extends BoundedSeriesConfig>(config: T) => (() => Result<T>);
|
|
85
|
+
declare const createGeneratorByType: <T extends AllConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
86
|
+
|
|
87
|
+
export { type ArrayConfig, type BoundedSeriesConfig, type ObjectConfig, type Result, type SelectionConfig, type TupleConfig, type ValueConfig, createArrayConfig, createArrayGenerator, createBoundedSeriesConfig, createBoundedSeriesGenerator, createGeneratorByType, createObjectConfig, createObjectGenerator, createSelectionConfig, createSelectionGenerator, createTupleConfig, createTupleGenerator, createValueConfig, createValueGenerator };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
type ValueConfig<T> = {
|
|
2
|
+
type: "value";
|
|
3
|
+
generateFn: () => T;
|
|
4
|
+
};
|
|
5
|
+
type SelectionConfig<T> = {
|
|
6
|
+
type: "select";
|
|
7
|
+
items: T[];
|
|
8
|
+
};
|
|
9
|
+
type BoundedSeriesConfig = {
|
|
10
|
+
type: "bounded_series";
|
|
11
|
+
upperLimit: number;
|
|
12
|
+
lowerLimit: number;
|
|
13
|
+
createInitValue: () => number;
|
|
14
|
+
count: number;
|
|
15
|
+
};
|
|
16
|
+
type ArrayConfig<T> = {
|
|
17
|
+
type: "arr";
|
|
18
|
+
item: T;
|
|
19
|
+
len: number;
|
|
20
|
+
};
|
|
21
|
+
type ObjectConfig<T> = {
|
|
22
|
+
type: "obj";
|
|
23
|
+
content: T;
|
|
24
|
+
};
|
|
25
|
+
type TupleConfig<A, B = undefined, C = undefined, D = undefined, E = undefined> = {
|
|
26
|
+
type: "tuple";
|
|
27
|
+
configItems: E extends undefined ? D extends undefined ? C extends undefined ? B extends undefined ? [A] : [A, B] : [A, B, C] : [A, B, C, D] : [A, B, C, D, E];
|
|
28
|
+
};
|
|
29
|
+
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 ObjectConfig<infer O> ? {
|
|
30
|
+
[K in keyof O]: Result<O[K]>;
|
|
31
|
+
} : T extends TupleConfig<infer A, infer B, infer C, infer D, infer E> ? E extends undefined ? D extends undefined ? C extends undefined ? B extends undefined ? [Result<A>] : [Result<A>, Result<B>] : [Result<A>, Result<B>, Result<C>] : [Result<A>, Result<B>, Result<C>, Result<D>] : [Result<A>, Result<B>, Result<C>, Result<D>, Result<E>] : never;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* value
|
|
35
|
+
* @param {function} generateFn - The function used to generate the value.
|
|
36
|
+
* @return {ValueConfig} The configuration object with the type "value" and the provided generate function.
|
|
37
|
+
*/
|
|
38
|
+
declare const createValueConfig: <T>(generateFn: () => T) => ValueConfig<T>;
|
|
39
|
+
/**
|
|
40
|
+
* selection
|
|
41
|
+
* @param {Array} items - The array of items to choose from.
|
|
42
|
+
* @return {SelectionConfig} The configuration object with the type "select" and the provided items.
|
|
43
|
+
*/
|
|
44
|
+
declare const createSelectionConfig: <T>(items: T[]) => SelectionConfig<T>;
|
|
45
|
+
/**
|
|
46
|
+
* object
|
|
47
|
+
* @param {object} content
|
|
48
|
+
* @return {ObjectConfig}
|
|
49
|
+
*/
|
|
50
|
+
declare const createObjectConfig: <T extends object>(content: T) => ObjectConfig<T>;
|
|
51
|
+
/**
|
|
52
|
+
* array
|
|
53
|
+
* @param {object} item
|
|
54
|
+
* @param {number} len
|
|
55
|
+
* @return {ArrayConfig}
|
|
56
|
+
*/
|
|
57
|
+
declare const createArrayConfig: <T>(item: T, len: number) => ArrayConfig<T>;
|
|
58
|
+
/**
|
|
59
|
+
* tuple
|
|
60
|
+
* @param {Array} configItems
|
|
61
|
+
* @return {TupleConfig}
|
|
62
|
+
*/
|
|
63
|
+
interface CreateTupleConfig {
|
|
64
|
+
<A, B, C, D, E>(configItems: [A, B, C, D, E]): TupleConfig<A, B, C, D, E>;
|
|
65
|
+
<A, B, C, D>(configItems: [A, B, C, D]): TupleConfig<A, B, C, D>;
|
|
66
|
+
<A, B, C>(configItems: [A, B, C]): TupleConfig<A, B, C>;
|
|
67
|
+
<A, B>(configItems: [A, B]): TupleConfig<A, B>;
|
|
68
|
+
<A>(configItems: [A]): TupleConfig<A>;
|
|
69
|
+
}
|
|
70
|
+
declare const createTupleConfig: CreateTupleConfig;
|
|
71
|
+
/**
|
|
72
|
+
* bounded series
|
|
73
|
+
* @param {{ upperLimit: number, lowerLimit: number, createInitValue: () => number, count: number }} config
|
|
74
|
+
* @return {BoundedSeriesConfig}
|
|
75
|
+
*/
|
|
76
|
+
declare const createBoundedSeriesConfig: (config: Omit<BoundedSeriesConfig, "type">) => BoundedSeriesConfig;
|
|
77
|
+
|
|
78
|
+
type AllConfig<T> = ValueConfig<T> | SelectionConfig<T> | ArrayConfig<T> | ObjectConfig<T> | TupleConfig<T> | TupleConfig<T, T> | TupleConfig<T, T, T> | TupleConfig<T, T, T, T> | TupleConfig<T, T, T, T, T> | BoundedSeriesConfig;
|
|
79
|
+
declare const createValueGenerator: <R = unknown>(config: ValueConfig<unknown>) => (() => R);
|
|
80
|
+
declare const createSelectionGenerator: <T extends SelectionConfig<unknown>>(config: T) => (() => Result<T>);
|
|
81
|
+
declare const createObjectGenerator: <T extends ObjectConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
82
|
+
declare const createArrayGenerator: <T extends ArrayConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
83
|
+
declare const createTupleGenerator: <T extends TupleConfig<unknown, unknown, unknown, unknown, unknown> | TupleConfig<unknown, unknown, unknown, unknown> | TupleConfig<unknown, unknown, unknown> | TupleConfig<unknown, unknown> | TupleConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
84
|
+
declare const createBoundedSeriesGenerator: <T extends BoundedSeriesConfig>(config: T) => (() => Result<T>);
|
|
85
|
+
declare const createGeneratorByType: <T extends AllConfig<unknown>>(config: T, customTypeMatch?: (config: unknown, path?: string) => ValueConfig<unknown>) => (() => Result<T>);
|
|
86
|
+
|
|
87
|
+
export { type ArrayConfig, type BoundedSeriesConfig, type ObjectConfig, type Result, type SelectionConfig, type TupleConfig, type ValueConfig, createArrayConfig, createArrayGenerator, createBoundedSeriesConfig, createBoundedSeriesGenerator, createGeneratorByType, createObjectConfig, createObjectGenerator, createSelectionConfig, createSelectionGenerator, createTupleConfig, createTupleGenerator, createValueConfig, createValueGenerator };
|