stream-api.js 479 B

123456789101112131415
  1. var readdirp = require('..')
  2. , path = require('path');
  3. readdirp({ root: path.join(__dirname), fileFilter: '*.js' })
  4. .on('warn', function (err) {
  5. console.error('something went wrong when processing an entry', err);
  6. })
  7. .on('error', function (err) {
  8. console.error('something went fatally wrong and the stream was aborted', err);
  9. })
  10. .on('data', function (entry) {
  11. console.log('%s is ready for processing', entry.path);
  12. // process entry here
  13. });