ixfx
    Preparing search index...

    Function yieldNumber

    • Returns a function that yields a value from a generator.

      const spring = yieldNumber(Oscillators.spring());

      spring(); // latest value

      Instead of:

      const spring = Oscillators.spring();

      spring.next().value

      A defaultValue can be provided if the source generator returns undefined:

      const spring = yieldNumber(Oscillators.spring(), 0);
      spring(); // Returns 0 if the generator returns undefined

      Parameters

      • generator: Generator<number>
      • OptionaldefaultValue: number

      Returns () => undefined | number