• Wait for and return the next truthy value (or error) from a data source (when processed with yield * within a Job).

    This differs from next() in that it waits for the next "truthy" value (i.e., not null, false, zero, empty string, etc.), and when used with signals or a signal-using function, it can resume immediately if the result is already truthy. (It also supports zero-argument signal-using functions, automatically wrapping them with cached(), as the common use case for until() is to wait for an arbitrary condition to be satisfied.)

    Type Parameters

    • T

    Parameters

    • source: UntilMethod<T> | Stream<T> | (() => T)

      The source to wait on, which can be:

      • An object with an "uneventful.until" method returning a Yielding (in which case the result will be the the result of calling that method)
      • A Signal, or a zero-argument function returning a value based on signals (in which case the job resumes as soon as the result is truthy, perhaps immediately)
      • A Source (in which case the job resumes on the next truthy value it produces

      (Note: if the supplied source is a function with a non-zero .length, it is assumed to be a Source.)

    Returns Yielding<T>

    a Yieldable that when processed with yield * in a job, will return the triggered event, or signal value. An error is thrown if event stream throws or closes early, or the signal throws.