From 0fc2cd1989d55f6e1966b859fc73293ac1ba91a2 Mon Sep 17 00:00:00 2001 From: Beno!t POLASZEK Date: Thu, 30 May 2024 15:14:37 +0200 Subject: [PATCH] doc: update --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 9373105..230832e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This package provides functions to work with [iterables](https://wiki.php.net/rf - [iterable_reduce()](#iterable_reduce) - [iterable_filter()](#iterable_filter) - [iterable_values()](#iterable_values) +- [iterable_chunk()](#iterable_chunk) iterable_to_array() ------------------- @@ -170,6 +171,33 @@ foreach (iterable_values($generator()) as $key => $value) { } ``` +iterable_chunk() +-------------- + +Here's an `array_chunk`-like function that also works with a `Traversable`. + +```php +use function BenTools\IterableFunctions\iterable_chunk; + +$fruits = [ + 'banana', + 'apple', + 'strawberry', + 'raspberry', + 'pineapple', +] +$fruits = (fn () => yield from $fruits)() +iterable_chunk($fruits, 2); + +/* + [ + ['banana', 'apple'], + ['strawberry', 'raspberry'], + ['pineapple'], + ] + */ +``` + Iterable fluent interface =========================