amphp / pipeline

Concurrent iterators and pipeline operations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Review: fromIterable

kelunik opened this issue · comments

I guess this could move to a static method on Pipeline? Maybe even split it into fromClosure and fromIterable?

/** @psalm-suppress RedundantConditionGivenDocblockType */
if (!$iterable instanceof \Generator) {
    $iterable = (static fn () => yield from $iterable)();
}

I'm not sure why this code exists.

Our current intermediate operations do all nothing until there's a terminal operation, but fromIterable starts iterating right away currently.

Two methods on Pipeline makes a lot of sense I think. Maybe all the functions should be static methods on Pipeline now?

I'm not sure why this code exists.

Probably a leftover from when pipelines were always created from generators. Not sure.