mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
43 lines
827 B
Markdown
43 lines
827 B
Markdown
# pull-stream/throughs/flatten
|
|
|
|
## usage
|
|
### `flatten = require('pull-stream/throughs/flatten')`
|
|
### `flatten(streams)`
|
|
Turn a stream of streams or a stream of arrays into a stream of their items, (undoes group).
|
|
|
|
|
|
## example
|
|
```js
|
|
test('flatten arrays', function (t) {
|
|
pull(
|
|
pull.values([
|
|
[1, 2, 3],
|
|
[4, 5, 6],
|
|
[7, 8, 9]
|
|
]),
|
|
pull.flatten(),
|
|
pull.collect(function (err, numbers) {
|
|
t.deepEqual([1, 2, 3, 4, 5, 6, 7, 8, 9], numbers)
|
|
t.end()
|
|
})
|
|
)
|
|
})
|
|
|
|
test('flatten stream of streams', function (t) {
|
|
|
|
pull(
|
|
pull.values([
|
|
pull.values([1, 2, 3]),
|
|
pull.values([4, 5, 6]),
|
|
pull.values([7, 8, 9])
|
|
]),
|
|
pull.flatten(),
|
|
pull.collect(function (err, numbers) {
|
|
t.deepEqual([1, 2, 3, 4, 5, 6, 7, 8, 9], numbers)
|
|
t.end()
|
|
})
|
|
)
|
|
|
|
})
|
|
```
|