You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
474 B
24 lines
474 B
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
|