Function combineGeneratorFunctions

  • 複数のGeneratorFunctionを組み合わせて実行するGeneratorFunctionを返す 具体的には内部で各Generatorを実行するラッパーGeneratorFunctionを生成する

    各Generatorのthisは本メソッドにおけるthisと一緒になる また引数指定した順番にGeneratorは実行される

    See

    https://runstant.com/pentamania/projects/858db919

    Example

    function *genFunc1() {
    console.log(this.name) // "alice"
    yield 3;
    yield 2;
    yield 1;
    }
    function *genFunc2() {
    yield "a";
    yield "b";
    }

    const context = {name: "alice"}
    const combined = combineGeneratorFunc.bind(context)(genFunc1, genFunc2)
    const combinedGenertor = combined()
    combinedGenertor.next() // run gen1 and gen2 simultaniously

    Parameters

    • this: any
    • Rest ...genFuncs: GeneratorFunction[]

      as rest paramnter

    Returns ((this: any) => Generator<IteratorYieldResult<unknown>[], null, unknown>)

      • (this: any): Generator<IteratorYieldResult<unknown>[], null, unknown>
      • Parameters

        • this: any

        Returns Generator<IteratorYieldResult<unknown>[], null, unknown>

Generated using TypeDoc