<commit_before>var isObject = require("lodash/lang/isObject");
var flatten = require("lodash/array/flatten");
var jsbeautify = require("js-beautify");
var esprima = require("esprima");

var PREDEF = require("./predef-ast");
var es = require("./es");
var ast = require("./ast");
var die = require("./die");
var fileWrapper = require("./file-wrapper");
var isJsReservedWord = require("./is-js-reserved-word");

function frozenArray(xs) {
    var fn = es.Identifier("$array");
    return es.CallExpression(fn, xs);
}

function transformAst(node) {
    if (!isObject(node)) {
        throw new Error("Not a node: " + jsonify(node));
    }
    if (handlers.hasOwnProperty(node.type)) {
        return handlers[node.type](node);
    }
    throw new Error("Unknown AST node: " + jsonify(node));
}

function unary(f) {
    return function(x) {
        return f(x);
    };
}

function mapLastSpecial(f, g, xs) {
    var n = xs.length;
    var ys = xs.slice(0, n - 1).map(unary(f));
    var y = unary(g)(xs[n - 1]);
    return ys.concat([y]);
}

function declareAssign(id, expr) {
    var init = es.VariableDeclarator(id, expr);
    return es.VariableDeclaration('var', [init]);
}

function freeze(esNode) {
    var freeze = is.Identifier("$freeze");
    return es.CallExpression(freeze, [esNode]);
}

function jsonify(x) {
    return JSON.stringify(x);
}

function literal(node) {
    return es.Literal(node.data);
}

function assertBoolean(x) {
    var id = ast.Identifier("$bool");
    var call = ast.Call(id, [x]);
    return transformAst(call);
}

function moduleExportsEq(x) {
    var moduleExports =
        es.MemberExpression(
            false,
            es.Identifier('module'),
            es.Identifier('exports')
        );
    return es.AssignmentExpression('=', moduleExports, x);
}

function globalComputedEq(name, x) {
    var literallyThis = es.Literal("this");
    var indirectEval = es.LogicalExpression("||",
        es.Literal(false),<commit_msg>Fixes name clash breaking TravisCI<commit_after>var isObject = require("lodash/lang/isObject");
var flatten = require("lodash/array/flatten");
var jsbeautify = require("js-beautify");
var esprima = require("esprima");

var PREDEF = require("./predef-ast");
var es = require("./es");
var ast = require("./ast");
var die = require("./die");
var fileWrapper = require("./file-wrapper");
var isJsReservedWord = require("./is-js-reserved-word");

function frozenArray(xs) {
    var fn = es.Identifier("$array");
    return es.CallExpression(fn, xs);
}

function transformAst(node) {
    if (!isObject(node)) {
        throw new Error("Not a node: " + jsonify(node));
    }
    if (handlers.hasOwnProperty(node.type)) {
        return handlers[node.type](node);
    }
    throw new Error("Unknown AST node: " + jsonify(node));
}

function unary(f) {
    return function(x) {
        return f(x);
    };
}

function mapLastSpecial(f, g, xs) {
    var n = xs.length;
    var ys = xs.slice(0, n - 1).map(unary(f));
    var y = unary(g)(xs[n - 1]);
    return ys.concat([y]);
}

function declareAssign(id, expr) {
    var init = es.VariableDeclarator(id, expr);
    return es.VariableDeclaration('var', [init]);
}

function freeze(esNode) {
    var id = is.Identifier("$freeze");
    return es.CallExpression(id, [esNode]);
}

function jsonify(x) {
    return JSON.stringify(x);
}

function literal(node) {
    return es.Literal(node.data);
}

function assertBoolean(x) {
    var id = ast.Identifier("$bool");
    var call = ast.Call(id, [x]);
    return transformAst(call);
}

function moduleExportsEq(x) {
    var moduleExports =
        es.MemberExpression(
            false,
            es.Identifier('module'),
            es.Identifier('exports')
        );
    return es.AssignmentExpression('=', moduleExports, x);
}

function globalComputedEq(name, x) {
    var literallyThis = es.Literal("this");
    var indirectEval = es.LogicalExpression("||",
        es.Literal(false),
{'fraction_non_alphanumeric': 0.16518424396442186, 'fraction_numerical': 0.0015247776365946632, 'mean_word_length': 3.4076147816349383, 'pattern_counts': {'":': 0, '<': 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': '4186621', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1293, 'n_words': 285}