Skip to content

Commit 262ce8c

Browse files
author
carlos
committed
changes in parse_json_lines.js (it takes the json from the stdin)
1 parent 6d8cdf0 commit 262ce8c

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

‎P02_nodejsutilities/package.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"version" : "0.0.1",
44
"dependencies": {
55
"http-proxy": ">= 0.10.3",
6-
"connect" : ">= 2.11.0",
6+
"connect" : ">= 2.7.8",
7+
"express":"2.5.4",
8+
"ntwitter":"0.2.10",
9+
"lazy":">=1.0.11",
710
"mkdirp" : ">= 0.3.5"
811
},
912

@@ -15,4 +18,3 @@
1518
"node": ">= 0.8.0"
1619
}
1720
}
18-
Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
if(process.argv.length<3){
2-
console.error("missing argument (file to parse)");
3-
return(-1);
4-
}
5-
6-
var fs = require('fs'),readline = require('readline');
7-
8-
var rd = readline.createInterface({
9-
input: fs.createReadStream(process.argv[2]),
10-
output: process.stdout,
11-
terminal: false
12-
});
13-
14-
rd.on('line', function(line) {
15-
try{
16-
var l=JSON.parse(line);
17-
console.log(JSON.stringify(l,null,4));
18-
}catch(error){}
19-
20-
});
1+
var Lazy=require("lazy");
2+
new Lazy(process.stdin).lines.forEach(
3+
function(line) {
4+
try{
5+
var l=JSON.parse(line);
6+
console.log(JSON.stringify(l,null,4));
7+
}catch(error){}
8+
}
9+
);
10+
process.stdin.resume();

0 commit comments

Comments
 (0)