aboutsummaryrefslogtreecommitdiff
path: root/node_modules/walkdir/test/comparison/fstream.js
blob: 1451b4caff31573c0cd8d771adb508f67b29f99c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var fstream = require('fstream');

var pipe = fstream.Reader(process.argv[2]||"../");

var count = 0,errorHandler;

pipe.on('entry',function fn(entry){
  if(entry.type == "Directory"){
  	entry.on('entry',fn);
  } else if(entry.type == "File") {
  	count++;
  }
  entry.on('error',errorHandler);
});

pipe.on('error',(errorHandler = function(error){
	console.log('error event ',error);
}));

pipe.on('end',function(){
	console.log('end! '+count);
});

//this is pretty slow