Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Commit

Permalink
add map and split examples
Browse files Browse the repository at this point in the history
  • Loading branch information
北川 committed Sep 4, 2018
1 parent a74c9b2 commit 0cc6c7f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/data
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"foo": 1}
{"foo": 2}
{"foo": 3, "bar": "test"}
15 changes: 15 additions & 0 deletions examples/map.js
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions examples/split.js
Original file line number Diff line number Diff line change
@@ -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"}

0 comments on commit 0cc6c7f

Please sign in to comment.