git ssb

3+

cel / ssb-npm-registry



Tree: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3

Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / stream-to-pull-stream / test / test-stdout.js

861 bytesRaw
1
2
3//i saw bugs with streams to stdout not ending correctly.
4//if there was a pause, it would not.
5
6
7var cp = require('child_process')
8var toPull = require('../')
9var pull = require('pull-stream')
10var split = require('pull-split')
11
12
13console.log(process.execPath, [require.resolve('./stdout')])
14var child = cp.spawn(process.execPath, [require.resolve('./stdout')])
15child.on('exit', function () {
16 console.log('ended')
17})
18pull(
19 toPull.source(child.stdout),
20 split('\n\n'),
21 pull.filter(),
22 pull.map(function (e) {
23 try {
24 return JSON.parse(e)
25 } catch (err) {
26 console.log(JSON.stringify(e))
27 //throw err
28 }
29
30 }),
31 pull.asyncMap(function (data, cb) {
32 setTimeout(function () {
33 cb(null, data)
34 }, 10)
35 }),
36 pull.drain(null, function (err) {
37 console.log('DONE')
38 if(err) throw err
39 console.log('done')
40 })
41)
42
43

Built with git-ssb-web