<commit_before>(function Xcon () {

    "use strict";

    // future-proof against vender expansions to browser console
    if (this.out || this.run) {
        window.xcon = {};
        return Xcon.call(window.xcon);
    }

    // private method that takes a raw input and determines
    // its primitive type.  Outputs all input as a string.
    function condition (blob) {
        var type = typeof blob;
        switch (type) {
            case 'number' || 'boolean' || 'function':
                blob = blob.toString();
                break;
            case 'object':
                type = blob instanceof Array ? 'array' : 'object';
                type = blob !== null ? type : 'null';
                blob = JSON.stringify(blob);
                break;
            case 'undefined':
                blob = 'undefined';
                break;
        }
        return {
            "type": type,
            "text": blob
        };
    }

    // returns a random color to improve contrast between
    // adjacent .out logs.  Colors should be non-red and
    // non-green to differentiate between .run() and .out()
    // logs.
    function colorSelect () {
        var outColors = [
            'blue',
            'darkgray',
            'black',
            'darkorange',
            'chocolate',
            'brown',
            'darkmagenta',
            'darkgoldenrod',
            'darkslateblue',
            'dimgray',
            'indigo',
            'maroon',
            'midnightblue',
            'navy',
            'purple',
            'royalblue',
            'sienna',
            'saddlebrown',
            'slateblue',
            'slategray',
            'teal',
            'steelblue'
        ],
        random = Math.floor(Math.random() * outColors.length);
        return outColors[random];
    }

    // skins a console.log message to display the primitive type as well
    // as the expected output of a vanilla .log() command
    // opts: {
    //     "color": "#f9f9f9", // specify a css color
    //     "log": true //
    // }
    // sometimes this function is called from console.run() to output
    // function return values.  In that case,
    // opts: {
    //     "color": "darkgreen", // or red
    //     "fnName": "nameOfFunction",
    //     "fnArgs": "all passed arguments",
    //     "error": true // indicates a thrown error
    // }
    this.out = function (blob, opts) {
        opts = opts || {};
        var props = condition(blob),
            type = props.type,
            text = props.text || '',
            color = opts.color || colorSelect(),
            fontWeight = opts.fnName ? "bold" : "normal";
        type = opts.error ? 'error' : type;
        type = opts.fnName ? opts.fnName + '(' +
            opts.fnArgs + ') returns ' + type : type;
        console.log("%c" + type + ":\n" + text,
            "color:" + color + ";font-weight:" + fontWeight);
        if (opts.log) {
            console.log(blob);
        }
    };

    // given a function, calls that function, returns the output,
    // and calls .out() to skin the output in green (success)
    // or red (failure).  Arguments, function name, and any error
    // messages are logged.
    this.run = function (fn, args, context) {
        if (typeof fn === 'function') {
            context = context || this;
            args = args || [];
            var n, result;
            try {
                result = fn.apply(context, args);
                this.out(result, {
                    "color": 'darkgreen',
                    "fnName": fn.name || 'anonymous function',
                    "fnArgs": args.toString()
                });
                return result;
            } catch (e) {
                this.out(e.message, {
                    "color": 'red',
                    "fnName": fn.name || 'anonymous function',
                    "fnArgs": args.toString(),
                    "error": true
                });
            }
        } else {
            this.out(arguments[0], arguments[1]);<commit_msg>refactor .run() to get rid of else{} block<commit_after>(function Xcon () {

    "use strict";

    // future-proof against vender expansions to browser console
    if (this.out || this.run) {
        window.xcon = {};
        return Xcon.call(window.xcon);
    }

    // private method that takes a raw input and determines
    // its primitive type.  Outputs all input as a string.
    function condition (blob) {
        var type = typeof blob;
        switch (type) {
            case 'number' || 'boolean' || 'function':
                blob = blob.toString();
                break;
            case 'object':
                type = blob instanceof Array ? 'array' : 'object';
                type = blob !== null ? type : 'null';
                blob = JSON.stringify(blob);
                break;
            case 'undefined':
                blob = 'undefined';
                break;
        }
        return {
            "type": type,
            "text": blob
        };
    }

    // returns a random color to improve contrast between
    // adjacent .out logs.  Colors should be non-red and
    // non-green to differentiate between .run() and .out()
    // logs.
    function colorSelect () {
        var outColors = [
            'blue',
            'darkgray',
            'black',
            'darkorange',
            'chocolate',
            'brown',
            'darkmagenta',
            'darkgoldenrod',
            'darkslateblue',
            'dimgray',
            'indigo',
            'maroon',
            'midnightblue',
            'navy',
            'purple',
            'royalblue',
            'sienna',
            'saddlebrown',
            'slateblue',
            'slategray',
            'teal',
            'steelblue'
        ],
        random = Math.floor(Math.random() * outColors.length);
        return outColors[random];
    }

    // skins a console.log message to display the primitive type as well
    // as the expected output of a vanilla .log() command
    // opts: {
    //     "color": "#f9f9f9", // specify a css color
    //     "log": true //
    // }
    // sometimes this function is called from console.run() to output
    // function return values.  In that case,
    // opts: {
    //     "color": "darkgreen", // or red
    //     "fnName": "nameOfFunction",
    //     "fnArgs": "all passed arguments",
    //     "error": true // indicates a thrown error
    // }
    this.out = function (blob, opts) {
        opts = opts || {};
        var props = condition(blob),
            type = props.type,
            text = props.text || '',
            color = opts.color || colorSelect(),
            fontWeight = opts.fnName ? "bold" : "normal";
        type = opts.error ? 'error' : type;
        type = opts.fnName ? opts.fnName + '(' +
            opts.fnArgs + ') returns ' + type : type;
        console.log("%c" + type + ":\n" + text,
            "color:" + color + ";font-weight:" + fontWeight);
        if (opts.log) {
            console.log(blob);
        }
    };

    // given a function, calls that function, returns the output,
    // and calls .out() to skin the output in green (success)
    // or red (failure).  Arguments, function name, and any error
    // messages are logged.
    this.run = function (fn, args, context) {
        if (typeof fn !== 'function') {
            this.out(arguments[0], arguments[1]);
            return arguments[0];
        }
        context = context || this;
        args = args || [];
        try {
            var result = fn.apply(context, args);
            this.out(result, {
                "color": 'darkgreen',
                "fnName": fn.name || 'anonymous function',
                "fnArgs": args.toString()
            });
            return result;
        } catch (e) {
            this.out(e.message, {
                "color": 'red',
                "fnName": fn.name || 'anonymous function',
                "fnArgs": args.toString(),
                "error": true
            });
{'fraction_non_alphanumeric': 0.13221094330279773, 'fraction_numerical': 0.001361723198811587, 'mean_word_length': 1.374779541446208, 'pattern_counts': {'":': 32, '<': 3, '<?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': '559315', 'n_tokens_mistral': 2200, 'n_tokens_neox': 2131, 'n_words': 633}