Skip to main content

Function: chainUntil()

chainUntil<T>(startArb, chainer): Arbitrary<T>

Defined in: packages/fast-check/src/arbitrary/chainUntil.ts:155

Build an arbitrary by iteratively chaining arbitraries until the chainer returns undefined.

Starting from a value produced by startArb, the chainer function is called with the current value to produce the next arbitrary. This process repeats until chainer returns undefined. The final value in the chain is the one produced by this arbitrary.

The implementation is fully iterative (non-recursive) and supports shrinking.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
startArbArbitrary<T>The starting arbitrary producing the initial value
chainer(prev) => Arbitrary<T> | undefinedA function called with the current value that returns either the next arbitrary to generate from or undefined to stop the chain

Returns

Arbitrary<T>

An arbitrary producing the last value in the chain

Remarks

Since 4.8.0