1 var readdirp = require('..')
2 , path = require('path')
3 , through = require('through2')
5 // print out all JavaScript files along with their size
6 readdirp({ root: path.join(__dirname), fileFilter: '*.js' })
7 .on('warn', function (err) { console.error('non-fatal error', err); })
8 .on('error', function (err) { console.error('fatal error', err); })
9 .pipe(through.obj(function (entry, _, cb) {
10 this.push({ path: entry.path, size: entry.stat.size });
14 function (res, _, cb) {
15 this.push(JSON.stringify(res) + '\n');
19 .pipe(process.stdout);