diff --git a/examples/data b/examples/data new file mode 100644 index 0000000..6352e02 --- /dev/null +++ b/examples/data @@ -0,0 +1,3 @@ +{"foo": 1} +{"foo": 2} +{"foo": 3, "bar": "test"} \ No newline at end of file diff --git a/examples/map.js b/examples/map.js new file mode 100644 index 0000000..02eb840 --- /dev/null +++ b/examples/map.js @@ -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 \ No newline at end of file diff --git a/examples/split.js b/examples/split.js new file mode 100644 index 0000000..34fc6a7 --- /dev/null +++ b/examples/split.js @@ -0,0 +1,12 @@ +var es = require('..') + +process.stdin + .pipe(es.split()) + .on('data', function (data) { + console.log('data: ' + data) + }) + +// cat data | node map.js +// data: {"foo": 1} +// data: {"foo": 2} +// data: {"foo": 3, "bar": "test"} \ No newline at end of file