pisc / genflow
Generator utilities library
1.0.1
2024-10-09 19:54 UTC
Requires (Dev)
- pestphp/pest: ^3.3.0
- phpstan/phpstan: ^1.12.6
README
Library to easily map, filter and reduce on a Generator.
Install
composer require pisc/genflow
Usage
<?php namespace MyNamespace; use function Pisc\GenFlow\gen; function myGenerator() { yield 1; yield 2; yield 3; } gen(myGenerator()) ->map(fn ($item) => $item * 2) ->filter(fn ($item) => $item < 5) ->toArray(); // [2, 4]