Initial
This commit is contained in:
3
Client/node_modules/event-stream/examples/data
generated
vendored
Executable file
3
Client/node_modules/event-stream/examples/data
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
{"foo": 1}
|
||||
{"foo": 2}
|
||||
{"foo": 3, "bar": "test"}
|
||||
15
Client/node_modules/event-stream/examples/map.js
generated
vendored
Executable file
15
Client/node_modules/event-stream/examples/map.js
generated
vendored
Executable file
@@ -0,0 +1,15 @@
|
||||
var es = require('..')
|
||||
|
||||
process.stdin
|
||||
.pipe(es.map(function (data, callback) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i] == 0x61) {
|
||||
data[i] = 0x41
|
||||
}
|
||||
}
|
||||
callback(null, data)
|
||||
}))
|
||||
.pipe(process.stdout)
|
||||
|
||||
// echo abcdabcd | node map.js
|
||||
// AbcdAbcd
|
||||
18
Client/node_modules/event-stream/examples/pretty.js
generated
vendored
Executable file
18
Client/node_modules/event-stream/examples/pretty.js
generated
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
|
||||
var inspect = require('util').inspect
|
||||
var es = require('..')
|
||||
|
||||
es.pipe( //pipe joins streams together
|
||||
process.openStdin(), //open stdin
|
||||
es.split(null, null, {trailing: false}), //split stream to break on newlines
|
||||
es.map(function (data, callback) { //turn this async function into a stream
|
||||
var obj = JSON.parse(data) //parse input into json
|
||||
callback(null, inspect(obj) + '\n') //render it nicely
|
||||
}),
|
||||
process.stdout // pipe it to stdout !
|
||||
)
|
||||
|
||||
// cat data | node pretty.js
|
||||
// { foo: 1 }
|
||||
// { foo: 2 }
|
||||
// { foo: 3, bar: 'test' }
|
||||
12
Client/node_modules/event-stream/examples/split.js
generated
vendored
Executable file
12
Client/node_modules/event-stream/examples/split.js
generated
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
var es = require('..')
|
||||
|
||||
process.stdin
|
||||
.pipe(es.split(null, null, {trailing: false})) // ignore trailing empty line
|
||||
.on('data', function (data) {
|
||||
console.log('data: ' + data)
|
||||
})
|
||||
|
||||
// cat data | node map.js
|
||||
// data: {"foo": 1}
|
||||
// data: {"foo": 2}
|
||||
// data: {"foo": 3, "bar": "test"}
|
||||
Reference in New Issue
Block a user