<commit_before>/**
 * Developer: BelirafoN
 * Date: 15.04.2016
 * Time: 15:39
 */

"use strict";

const CRLF = '\r\n',
    assert = require('assert'),
    path = require('path'),
    fs = require('fs'),
    AmiEventEmitter = require('../lib/AmiEventsStream');

describe('AmiEventsStream internal functionality', function() {
    this.timeout(process.env.MOCHA_TIMEOUT || 2000);

    let eventEmitter = null,
        readStream = null;

    beforeEach(() => {
        eventEmitter = new AmiEventEmitter(event => {
            return event
                .toString('utf-8')
                .replace(/^[\r\n]+|[\r\n]+$/g, '')
                .split(CRLF)
                .reduce((obj, curr) => {
                    let pair = curr.split(/:\s|:$/);
                    obj[pair[0]] = pair.length > 1 ? pair[1] : null;
                    return obj;
                }, {})
        });
        readStream = fs.createReadStream(path.join(__dirname, './fixtures/ami.dump'));<commit_msg>added error handlers for readStream<commit_after>/**
 * Developer: BelirafoN
 * Date: 15.04.2016
 * Time: 15:39
 */

"use strict";

const CRLF = '\r\n',
    assert = require('assert'),
    path = require('path'),
    fs = require('fs'),
    AmiEventEmitter = require('../lib/AmiEventsStream');

describe('AmiEventsStream internal functionality', function() {
    this.timeout(process.env.MOCHA_TIMEOUT || 2000);

    let eventEmitter = null,
        readStream = null;

    beforeEach(() => {
        eventEmitter = new AmiEventEmitter(event => {
            return event
                .toString('utf-8')
                .replace(/^[\r\n]+|[\r\n]+$/g, '')
                .split(CRLF)
                .reduce((obj, curr) => {
                    let pair = curr.split(/:\s|:$/);
                    obj[pair[0]] = pair.length > 1 ? pair[1] : null;
                    return obj;
                }, {})
        });
        readStream = fs.createReadStream(path.join(__dirname, './fixtures/ami.dump'));
        readStream.on('error', error => console.log(error));
{'fraction_non_alphanumeric': 0.17212713936430318, 'fraction_numerical': 0.019559902200488997, 'mean_word_length': 1.9270386266094421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3683843', 'n_tokens_mistral': 660, 'n_tokens_neox': 614, 'n_words': 116}