Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50659 views
1
2
var inspect = require('util').inspect
3
4
if(!module.parent) {
5
var es = require('..') //load event-stream
6
es.pipe( //pipe joins streams together
7
process.openStdin(), //open stdin
8
es.split(), //split stream to break on newlines
9
es.map(function (data, callback) {//turn this async function into a stream
10
var j
11
try {
12
j = JSON.parse(data) //try to parse input into json
13
} catch (err) {
14
return callback(null, data) //if it fails just pass it anyway
15
}
16
callback(null, inspect(j)) //render it nicely
17
}),
18
process.stdout // pipe it to stdout !
19
)
20
}
21
22
// run this
23
//
24
// curl -sS registry.npmjs.org/event-stream | node pretty.js
25
//
26
27