> */ private $promise; /** * @param Stream $stream * @param callable(TValue):void $each */ public function __construct(Stream $stream, callable $each) { $this->promise = call(function () use ($stream, $each) { while (list($value, $key) = yield $stream->continue()) { yield call($each, $value, $key); } }); } /** * @return Promise> */ public function promise(): Promise { return $this->promise; } }