<commit_before>**Table of Contents**  *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [Installation](#installation)
- [readdir](#readdir)
	- [Signature](#signature)
		- [options](#options)
		- [allProcessed ](#allprocessed)
		- [fileProcessed](#fileprocessed)
		- [entry info](#entry-info)
	- [Filters](#filters)
	- [Examples](#examples)

# fsrec [![Build Status](https://secure.travis-ci.org/thlorenz/fsrec.png)](http://travis-ci.org/thlorenz/fsrec)

Recursive versions of [fs module](http://nodejs.org/docs/v0.6.6/api/fs.html) functions, so far `readdir`.

`mkdir` will not be implemented as there is already a great module for this:
[mkdirp](https://github.com/substack/node-mkdirp), so use that alongside fsrec.

`readFile` is yet to come and to request other other recursive versions of fs functions please do so [here](https://github.com/thlorenz/fsrec/issues/new).

# Installation

    npm install fsrec

# readdir

- reads given root recursively and returns list of files and directories with stats attached

## Signature

```javascript
fs.readdir (options, callback1 [, callback2]);
```

If callback2 (optional) is given, callback1 functions as the **fileProcessed** callback, and callback2 as the **allProcessed** callback.

If only callback1 is given, it functions as the **allProcessed** callback.


### options
    
- **root**: path in which to start reading and recursing into subdirectories

- **fileFilter**: filter to include/exclude files found (see [Filters](#filters) for more)

- **directoryFilter**: filter to include/exclude directories found and to recurse into (see [Filters](#filters) for more)

- **depth**: depth at which to stop recursing even if more subdirectories are found

### allProcessed 

- function with err and res parameters, e.g., `function (err, res) { ... }`
- **err**: array of errors that occurred during the operation, **res may still be present, even if errors occurred**
- **res**: collection of file/directory [entry infos](#entry-info) which each have the following structure:

### fileProcessed

- function with [entry info](#entry-info) parameter e.g., `function (entryInfo) { ... }`

### entry info<commit_msg>minor fix<commit_after>**Table of Contents**  *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [Installation](#installation)
- [readdir](#readdir)
	- [Signature](#signature)
		- [options](#options)
		- [allProcessed ](#allprocessed)
		- [fileProcessed](#fileprocessed)
		- [entry info](#entry-info)
	- [Filters](#filters)
	- [Examples](#examples)

# fsrec [![Build Status](https://secure.travis-ci.org/thlorenz/fsrec.png)](http://travis-ci.org/thlorenz/fsrec)

Recursive versions of [fs module](http://nodejs.org/docs/v0.6.6/api/fs.html) functions, so far `readdir`.

`mkdir` will not be implemented as there is already a great module for this:
[mkdirp](https://github.com/substack/node-mkdirp), so use that alongside fsrec.

`readFile` is yet to come and to request other other recursive versions of fs functions please do so [here](https://github.com/thlorenz/fsrec/issues/new).

# Installation

    npm install fsrec

# readdir

- reads given root recursively and returns list of files and directories with stats attached

## Signature

```javascript
fs.readdir (options, callback1 [, callback2]);
```

If callback2 (optional) is given, callback1 functions as the **fileProcessed** callback, and callback2 as the **allProcessed** callback.

If only callback1 is given, it functions as the **allProcessed** callback.


### options
    
- **root**: path in which to start reading and recursing into subdirectories

- **fileFilter**: filter to include/exclude files found (see [Filters](#filters) for more)

- **directoryFilter**: filter to include/exclude directories found and to recurse into (see [Filters](#filters) for more)

- **depth**: depth at which to stop recursing even if more subdirectories are found

### allProcessed 

- function with err and res parameters, e.g., `function (err, res) { ... }`
- **err**: array of errors that occurred during the operation, **res may still be present, even if errors occurred**
- **res**: collection of file/directory [entry infos](#entry-info)

### fileProcessed

- function with [entry info](#entry-info) parameter e.g., `function (entryInfo) { ... }`

### entry info
{'fraction_non_alphanumeric': 0.13920520567046246, 'fraction_numerical': 0.004183128050197537, 'mean_word_length': 4.663157894736842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, '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': '4832166', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1266, 'n_words': 438}