-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathread.js
More file actions
30 lines (27 loc) · 880 Bytes
/
read.js
File metadata and controls
30 lines (27 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var ReadStream = require('./lib/readStream.js');
/**** non-flowing mode ****/
var startNonFlowing = function(cb) {
console.log('starting read stream in non-flowing mode.');
var rs = new ReadStream();
rs.on('readable', function() {
while (null !== (record = rs.read())) {
console.log('received : ' + JSON.stringify(record));
}
});
rs.on('end', function() {
console.log('done with read stream in non-flowing mode.\n');
cb();
});
};
/**** flowing mode ****/
var startFlowing = function() {
console.log('starting read stream in flowing mode.');
var rs = new ReadStream();
rs.on('data', function(record) {
console.log('received : ' + JSON.stringify(record));
});
rs.on('end', function() {
console.log('done with read stream in flowing mode.\n');
});
};
startNonFlowing(startFlowing);