fiisoft/jackdaw-stream
一个强大且独特的库,用于在可迭代数据上提供类似流操作。充满bug,但仍然很有趣。
8.0.0
2024-07-12 13:35 UTC
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-09-20 14:35:21 UTC
README
让我们将原生PHP数组操作封装到类似流的包装器中,类似于Java和Scala。就这样!
这个库具有许多其他地方没有的独特功能。你需要它们吗?不,永远不需要。
如何安装?
使用composer(fiisoft/jackdaw-stream)。代码与PHP 7.4及更高版本兼容。
如何开始?
通常从Stream::from(...)开始。例如
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);
让它流动!
文档
不存在。抱歉。
Stream类是这个代码的入口点,因此请查看这个类的公共方法及其类型提示。分析示例和测试。
免责声明
我可以在不预先通知的情况下更改这个库中的任何内容,尽管我尽量保持语义版本控制。
而且,一如既往:除非你足够强大,能够免疫这样的糟糕代码(以及我的床英语),否则请不要使用它。