innmind/async-stream
最新稳定版本:1.0.0
Composer 安装命令:
composer require innmind/async-stream
包简介
README 文档
README
Async implementation of innmind/stream to allow switching to another task when reading, writing or watching for streams.
Installation
composer require innmind/async-stream
Usage
use Innmind\Async\Stream\Streams; use Innmind\Stream\Streams as Synchronous; use Innmind\TimeContinuum\Earth\Clock; use Innmind\Url\Path; use Innmind\Mantle\{ Source\Predetermined, Suspend, Forerunner, }; $clock = new Clock; $synchronous = Synchronous::fromAmbientAuthority(); $source = Predetermined::of( static function(Suspend $suspend) use ($clock, $synchronous) { $stream = Streams::of($synchronous, $suspend, $clock) ->readable() ->open(Path::of('fixtures/first.txt')); while (!$stream->end()) { echo $stream->readLine()->match( static fn($line) => $line->toString(), static fn() => '', ); } }, static function(Suspend $suspend) use ($clock, $synchronous) { $stream = Streams::of($synchronous, $suspend, $clock) ->readable() ->open(Path::of('fixtures/second.txt')); while (!$stream->end()) { echo $stream->readLine()->match( static fn($line) => $line->toString(), static fn() => '', ); } }, ); Forerunner::of($clock)(null, $source); // will print interlaced lines of both files
统计信息
- 总下载量: 931
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-04