@hegeldev/hegel
    Preparing search index...

    Function deferred

    • A generator defined by a function called the first time it is drawn from (or its label is needed), so a definition can refer to generators defined after it, including itself:

      type Tree = null | [Tree, Tree];
      const tree: Generator<Tree> = deferred(() => oneOf<Tree>(just(null), tuples(tree, tree)));

      A definition that always refers back to itself is cut off by the engine's limit on nested spans, which rejects the test case. A definition that resolves only to itself throws when drawn from. For recursive data with engine-controlled size, prefer recursive. It prints as the generator definition returns does.

      Type Parameters

      • T

      Parameters

      Returns PrintableGenerator<T>

    • A generator defined by a function called the first time it is drawn from (or its label is needed), so a definition can refer to generators defined after it, including itself:

      type Tree = null | [Tree, Tree];
      const tree: Generator<Tree> = deferred(() => oneOf<Tree>(just(null), tuples(tree, tree)));

      A definition that always refers back to itself is cut off by the engine's limit on nested spans, which rejects the test case. A definition that resolves only to itself throws when drawn from. For recursive data with engine-controlled size, prefer recursive. It prints as the generator definition returns does.

      Type Parameters

      • T

      Parameters

      Returns Generator<T>