Function: memo()
memo<
T>(builder):Memo<T>
Defined in: packages/fast-check/src/arbitrary/memo.ts:33
For mutually recursive types
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
builder | (maxDepth) => Arbitrary<T> | Arbitrary builder taken the maximal depth allowed as input (parameter n) |
Returns
Memo<T>
Example
// tree is 1 / 3 of node, 2 / 3 of leaf
const tree: fc.Memo<Tree> = fc.memo(n => fc.oneof(node(n), leaf(), leaf()));
const node: fc.Memo<Tree> = fc.memo(n => {
if (n <= 1) return fc.record({ left: leaf(), right: leaf() });
return fc.record({ left: tree(), right: tree() }); // tree() is equivalent to tree(n-1)
});
const leaf = fc.nat;
Remarks
Since 1.16.0