<commit_before>/*global require */

var StdLib = require('./stdLib');
var ScopeHandler = require('./scopeHandler').create();
var Interpreter = require('./interpreter').create(ScopeHandler);
var Error = require('./error');

var createCore = function (parser, terminal, audio) {

    var Core = {};

    Core.Audio = audio;

    var globalScope = ScopeHandler.createScope();
    StdLib.addFunctions(Core, ScopeHandler, globalScope);

    Core.handleCode = function (code) {
        var ast;
        try {
            ast = parser.parse(code);
            Interpreter.evaluate(globalScope, ast);
        } catch (err) {
            if (err.websoundErr === true) {
                Core.displayError(err);
            } else {
                throw err;
            }
        }
    };

    Core.scheduleCallback = function (time, closure) {
        setTimeout(function () {
            try {
                Interpreter.apply(globalScope, closure, []);
            } catch (err) {
                if (err.websoundErr === true) {
                    Core.displayError(err);
                } else {
                    throw err;
                }
            }
        }, time);
    };

    Core.displayError = function (err) {
        var errLines;
        if (typeof err.message === 'string') {
            errLines = [err.message];
        } else {
            errLines = err.message;
        }
        var i;
        for (i = 0; i < errLines.length; i += 1) {
            terminal.error(errLines[i]);
        }
    };

    Core.display = function (data) {
        terminal.message(data);
    };

    return Core;
};

module.exports = {
    create: createCore
};
<commit_msg>Also log displayed data to console<commit_after>/*global require */

var StdLib = require('./stdLib');
var ScopeHandler = require('./scopeHandler').create();
var Interpreter = require('./interpreter').create(ScopeHandler);
var Error = require('./error');

var createCore = function (parser, terminal, audio) {

    var Core = {};

    Core.Audio = audio;

    var globalScope = ScopeHandler.createScope();
    StdLib.addFunctions(Core, ScopeHandler, globalScope);

    Core.handleCode = function (code) {
        var ast;
        try {
            ast = parser.parse(code);
            Interpreter.evaluate(globalScope, ast);
        } catch (err) {
            if (err.websoundErr === true) {
                Core.displayError(err);
            } else {
                throw err;
            }
        }
    };

    Core.scheduleCallback = function (time, closure) {
        setTimeout(function () {
            try {
                Interpreter.apply(globalScope, closure, []);
            } catch (err) {
                if (err.websoundErr === true) {
                    Core.displayError(err);
                } else {
                    throw err;
                }
            }
        }, time);
    };

    Core.displayError = function (err) {
        console.log(err);
        var errLines;
        if (typeof err.message === 'string') {
            errLines = [err.message];
        } else {
            errLines = err.message;
        }
        var i;
        for (i = 0; i < errLines.length; i += 1) {
            terminal.error(errLines[i]);
        }
    };

    Core.display = function (data) {
        console.log(data);
        terminal.message(data);
    };

    return Core;
};

module.exports = {
    create: createCore
};

{'fraction_non_alphanumeric': 0.1304093567251462, 'fraction_numerical': 0.0011695906432748538, 'mean_word_length': 1.6114503816793893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5347021', 'n_tokens_mistral': 965, 'n_tokens_neox': 929, 'n_words': 207}