Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1540,8 +1540,13 @@ object ZStreamSpec extends ZIOBaseSpec {
} yield assert(result)(equalTo(Chunk(1)))
}
),
testM("grouped")(
assertM(ZStream(1, 2, 3, 4).grouped(2).runCollect)(equalTo(Chunk(List(1, 2), List(3, 4))))
suite("grouped")(
testM("sanity") {
assertM(ZStream(1, 2, 3, 4, 5).grouped(2).runCollect)(equalTo(Chunk(List(1, 2), List(3, 4), List(5))))
},
testM("doesn't emit empty chunks") {
assertM(ZStream.fromIterable(List.empty[Int]).grouped(5).runCollect)(equalTo(Chunk.empty))
}
),
suite("groupedWithin")(
testM("group based on time passed") {
Expand Down
2 changes: 1 addition & 1 deletion streams/shared/src/main/scala/zio/stream/ZStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ abstract class ZStream[-R, +E, +O](val process: ZManaged[R, Nothing, ZIO[R, Opti
* @param chunkSize size of the chunk
*/
def grouped(chunkSize: Long): ZStream[R, E, List[O]] =
aggregate(ZTransducer.collectAllN(chunkSize))
aggregate(ZTransducer.collectAllN(chunkSize)).filter(_.nonEmpty)

/**
* Partitions the stream with the specified chunkSize or until the specified
Expand Down