1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 00:49:48 +01:00
amp/docs/iterators/transformation.md

18 lines
586 B
Markdown
Raw Normal View History

# Iterator Transformation
2017-03-18 08:39:41 +01:00
Amp provides two common transformation helpers for iterators: `map` and `filter`.
Further primitives are very easy to implement using `Producer` with those two as examples.
## `map()`
`map()` accepts an `Iterator` and a `callable` `$onEmit` that can transform each value into another value.
## `filter()`
`filter()` accepts an `Iterator` and a `callable` `$filter`. If `$filter($value)` returns `false` the value gets filtered, otherwise the value is retained in the resulting `Iterator`.
2017-05-03 12:49:56 +02:00
## Further Reading
* [Iterator Combination](./combinators.md)