Commit a81d5b4839992b6e494921404deee61709e162bf
Update docs
nichoth authored on 10/13/2016, 10:57:56 PMGitHub committed on 10/13/2016, 10:57:56 PM
Parent: 4820f821d54b2ca1d9ea1519cc0f56cd89b7fe98
Files changed
docs/throughs/flatten.md | changed |
docs/throughs/flatten.md | ||
---|---|---|
@@ -1,9 +1,44 @@ | ||
1 | 1 | # pull-stream/throughs/flatten |
2 | 2 | |
3 | +`flatten = require('pull-stream/throughs/flatten')` | |
4 | + | |
5 | +## example | |
6 | +```js | |
7 | +test('flatten arrays', function (t) { | |
8 | + pull( | |
9 | + pull.values([ | |
10 | + [1, 2, 3], | |
11 | + [4, 5, 6], | |
12 | + [7, 8, 9] | |
13 | + ]), | |
14 | + pull.flatten(), | |
15 | + pull.collect(function (err, numbers) { | |
16 | + t.deepEqual([1, 2, 3, 4, 5, 6, 7, 8, 9], numbers) | |
17 | + t.end() | |
18 | + }) | |
19 | + ) | |
20 | +}) | |
21 | + | |
22 | +test('flatten stream of streams', function (t) { | |
23 | + | |
24 | + pull( | |
25 | + pull.values([ | |
26 | + pull.values([1, 2, 3]), | |
27 | + pull.values([4, 5, 6]), | |
28 | + pull.values([7, 8, 9]) | |
29 | + ]), | |
30 | + pull.flatten(), | |
31 | + pull.collect(function (err, numbers) { | |
32 | + t.deepEqual([1, 2, 3, 4, 5, 6, 7, 8, 9], numbers) | |
33 | + t.end() | |
34 | + }) | |
35 | + ) | |
36 | + | |
37 | +}) | |
38 | +``` | |
39 | + | |
3 | 40 | ## usage |
4 | 41 | |
5 | -### `flatten = require('pull-stream/throughs/flatten')` | |
42 | +### `flatten(streams)` | |
6 | 43 | |
7 | -### `flatten()` | |
8 | - | |
9 | 44 | Turn a stream of streams or a stream of arrays into a stream of their items, (undoes group). |
Built with git-ssb-web