<commit_before># DirStream

Simple stream wrapper for `fs.readdir()`. Takes a path and streams the
contents of the target directory.

# Installation

Install with NPM:

`npm install dirstream`

# Usage

To get a stream of file names from a target directory just do:

    var path  = 'path/to/folder/to/scan';
    var files = require('dirstream').createStream(path);
    files.on('data', function (file) {
      console.log(file);
    });
    files.on('end', function () {
      console.log('All files logged! Fish: ><(( v ) ">');
    });

To get a stream of only the files that match a given pattern do:

    var path  = 'path/to/folder/to/scan';
    var pattern = /\.jpg$/;
    var files = require('dirstream').createStream(path, pattern);
    files.on('data', function (jpg) {
      console.log(file);
    });
    files.on('count', function (count) {
      console.log('Hang on for a stream of ' + count + ' files!');
    });

# Events

## count

`DirStream` will emit a `count` event after the results from `fs.readdir()`<commit_msg>Fixed and clarified filter example in readme. Thanks @cybear!<commit_after># DirStream

Simple stream wrapper for `fs.readdir()`. Takes a path and streams the
contents of the target directory.

# Installation

Install with NPM:

`npm install dirstream`

# Usage

To get a stream of file names from a target directory just do:

    var path  = 'path/to/folder/to/scan';
    var files = require('dirstream').createStream(path);
    files.on('data', function (file) {
      console.log(file);
    });
    files.on('end', function () {
      console.log('All files logged! Fish: ><(( v ) ">');
    });

To get a stream of only the files that match a given pattern do:

    var path  = 'path/to/folder/to/scan';
    var pattern = /\.jpg$/; // Only give me jpgs
    var files = require('dirstream').createStream(path, pattern);
    files.on('data', function (jpgname) {
      console.log(jpgname);
    });
    files.on('count', function (count) {
      console.log('Hang on for a stream of ' + count + ' files!');
    });

# Events

## count

`DirStream` will emit a `count` event after the results from `fs.readdir()`
{'fraction_non_alphanumeric': 0.1419925512104283, 'fraction_numerical': 0.0, 'mean_word_length': 3.189083820662768, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5116390', 'n_tokens_mistral': 686, 'n_tokens_neox': 666, 'n_words': 227}