UNPKG

1.91 kBTypeScriptView Raw
1import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';
2import type { SizeForArbitrary } from './_internals/helpers/MaxLengthFromMinLength.js';
3import type { DepthIdentifier } from './_internals/helpers/DepthContext.js';
4/**
5 * Constraints to be applied on {@link dictionary}
6 * @remarks Since 2.22.0
7 * @public
8 */
9export interface DictionaryConstraints {
10 /**
11 * Lower bound for the number of keys defined into the generated instance
12 * @defaultValue 0
13 * @remarks Since 2.22.0
14 */
15 minKeys?: number;
16 /**
17 * Lower bound for the number of keys defined into the generated instance
18 * @defaultValue 0x7fffffff — _defaulting seen as "max non specified" when `defaultSizeToMaxWhenMaxSpecified=true`_
19 * @remarks Since 2.22.0
20 */
21 maxKeys?: number;
22 /**
23 * Define how large the generated values should be (at max)
24 * @remarks Since 2.22.0
25 */
26 size?: SizeForArbitrary;
27 /**
28 * Depth identifier can be used to share the current depth between several instances.
29 *
30 * By default, if not specified, each instance of dictionary will have its own depth.
31 * In other words: you can have depth=1 in one while you have depth=100 in another one.
32 *
33 * @remarks Since 3.15.0
34 */
35 depthIdentifier?: DepthIdentifier | string;
36 /**
37 * Do not generate objects with null prototype
38 * @defaultValue true
39 * @remarks Since 3.13.0
40 */
41 noNullPrototype?: boolean;
42}
43/**
44 * For dictionaries with keys produced by `keyArb` and values from `valueArb`
45 *
46 * @param keyArb - Arbitrary used to generate the keys of the object
47 * @param valueArb - Arbitrary used to generate the values of the object
48 *
49 * @remarks Since 1.0.0
50 * @public
51 */
52export declare function dictionary<T>(keyArb: Arbitrary<string>, valueArb: Arbitrary<T>, constraints?: DictionaryConstraints): Arbitrary<Record<string, T>>;