Skip to content

Commit

Permalink
doc: update
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek committed May 30, 2024
1 parent 1e5f3af commit 0fc2cd1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
-------------------
Expand Down Expand Up @@ -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
=========================

Expand Down

0 comments on commit 0fc2cd1

Please sign in to comment.