-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump.js
20 lines (19 loc) · 908 Bytes
/
dump.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var reader = require('read-async-bson');
var fs = require('fs');
// How to run this: "cat your-bson-file | nodejs dump.js".
return reader(
{ from: process.stdin },
function(item, callback) {
// One BSON document, converted as a JavaScript object
fs.appendFileSync('dump/github/json/repos_no_comma.json', JSON.stringify(item) + '\n');
return callback(null);
},
function(err) {
// Called on error or at end of stream
if (!err) {
console.log('end of stream');
} else {
console.error(err);
}
}
);