fiisoft / jackdaw-stream
A powerfull and unique library to provide stream-like operations on iterable data. Full of bugs and still quite funny.
Requires
- php: >=7.4.0 <8.4.0
- ext-json: *
- ext-mbstring: *
Requires (Dev)
- infection/infection: >=0.26.6
- phpmd/phpmd: >=2.0.0
- phpstan/extension-installer: >=1.1.0
- phpstan/phpstan: >=1.10.31
- phpstan/phpstan-deprecation-rules: >=1.0.0
- phpstan/phpstan-phpunit: >=1.0.0
- phpunit/phpunit: >=9.3.0
- psr/log: >=1.0.0
- ramsey/uuid: >=4.0.0
- rector/rector: >=0.18.3
- squizlabs/php_codesniffer: >=3.4.0
- symfony/console: >=4.1.6
- symfony/uid: >=5.0.0
- vimeo/psalm: >=5.0.0
Suggests
- ext-pdo: To use PDOStatementAdapter as Producer for Stream
- aimeos/map: To call certain scripts in examples directory
- bertptrs/phpstreams: To call certain scripts in examples directory
- ebanx/stream: To call certain scripts in examples directory
- gowork/values: To call certain scripts in examples directory
- illuminate/collections: To call certain scripts in examples directory
- loophp/collection: To call certain scripts in examples directory
- psr/log: To use PsrLogger as error logger
- ramsey/uuid: To use RandomUuid generator (backed by ramsey/uuid) as Producer for Stream
- sanmai/pipeline: To call certain scripts in examples directory
- symfony/console: To use Symfony console output as error logger
- symfony/uid: To use RandomUuid generator (backed by symfony/uid) as Producer for Stream
This package is not auto-updated.
Last update: 2024-11-15 15:18:45 UTC
README
Let's wrap native PHP array operations into stream-like wrappers, similar to Java and Scala. And... here we are!
This library comes with tons of unique features not available elsewhere. Will you ever need them? No, never.
How to install?
Use composer (fiisoft/jackdaw-stream
). Code is compatible with PHP 7.4 up to the newest version.
How to start?
Typically it starts with Stream::from(...). For example:
Stream::from(Producers::sequentialInt()) ->mapKey(static fn(int $n): int => ($n % 3 === 0 ? 2 : 0) | ($n % 5 === 0 ? 1 : 0)) ->map(static fn(int $n, int $k): string => [$n, 'Buzz', 'Fizz', 'Fizz Buzz'][$k].', ') ->call(Consumers::usleep(100_000)) //slow down a bit ->forEach(STDOUT);
Let it flow!
Documentation
Does not exist. Sorry.
Class Stream is the entry point to this code, so look at public methods of this class, and their typehints. Analyse examples and tests.
Disclaimer
I can change anything in this library without warning, although I try to keep semantic versioning.
And as always: don't use it unless you're mentally strong enough to be immune to such bad code (and my bed English too).