<commit_before># Asynchronous File Reader
[![Greenkeeper badge](https://badges.greenkeeper.io/Thomas-P/async-file-reader.svg)](https://greenkeeper.io/) [![Build Status](https://travis-ci.org/Thomas-P/async-file-reader.svg?branch=master)](https://travis-ci.org/Thomas-P/async-file-reader) [![Coverage Status](https://coveralls.io/repos/github/Thomas-P/async-file-reader/badge.svg)](https://coveralls.io/github/Thomas-P/async-file-reader) [![Known Vulnerabilities](https://snyk.io/test/github/thomas-p/async-file-reader/badge.svg)](https://snyk.io/test/github/thomas-p/async-file-reader)


File reader allows to read a file line by line. The advantage by this module is that you can write your asynchronous code in a linear way. That reduces the complexity of code. Using readFileSync could become complicated, when you should handle large files.

Another feature is, that if you do not add a callback with `readLine()` the stream is posed and will not waste memory. 
## Usage
```typescript
const main = async () => {
    import {AsyncFileReader} from 'async-file-reader';
    const fileReader = new AsyncFileReader('README.md');
    let line: string;
    try {
        while ((line = await fileReader.readLine()) != null) {
            // do something
        } 
    } catch (error) {
        console.log('An Error happened while reading the file.');
    }
}

main()
    .catch(() => /* handle error in main function */ );
```
<commit_msg>quick typo fix<commit_after># Asynchronous File Reader
[![Greenkeeper badge](https://badges.greenkeeper.io/Thomas-P/async-file-reader.svg)](https://greenkeeper.io/) [![Build Status](https://travis-ci.org/Thomas-P/async-file-reader.svg?branch=master)](https://travis-ci.org/Thomas-P/async-file-reader) [![Coverage Status](https://coveralls.io/repos/github/Thomas-P/async-file-reader/badge.svg)](https://coveralls.io/github/Thomas-P/async-file-reader) [![Known Vulnerabilities](https://snyk.io/test/github/thomas-p/async-file-reader/badge.svg)](https://snyk.io/test/github/thomas-p/async-file-reader)


File reader allows to read a file line by line. The advantage by this module is that you can write your asynchronous code in a linear way. That reduces the complexity of code. Using readFileSync could become complicated, when you should handle large files.

Another feature is, that if you do not add a callback with `readLine()` the stream is paused and will not waste memory. 
## Usage
```typescript
import {AsyncFileReader} from 'async-file-reader';

const main = async () => {
    const fileReader = new AsyncFileReader('README.md');
    let line: string;
    try {
        while ((line = await fileReader.readLine()) != null) {
            // do something
        } 
    } catch (error) {
        console.log('An Error happened while reading the file.');
    }
}

main()
    .catch(() => /* handle error in main function */ );
```

{'fraction_non_alphanumeric': 0.1453913043478261, 'fraction_numerical': 0.0, 'mean_word_length': 3.777408637873754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 16, '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': '1808730', 'n_tokens_mistral': 897, 'n_tokens_neox': 853, 'n_words': 238}