<commit_before>var generator = require("./generation/generator");
var util      = require("./util");
var File      = require("./file");
var t         = require("./types");
var _         = require("lodash");

module.exports = function (namespace) {
  namespace = t.identifier(namespace || "to5Runtime");

  var body      = [];
  var container = t.functionExpression(null, [], t.blockStatement(body));
  var tree      = t.program([t.expressionStatement(t.callExpression(container, []))]);

  body.push(util.template("self-global", true));

  body.push(t.variableDeclaration("var", [
    t.variableDeclarator(
      namespace,
      t.assignmentExpression("=", t.memberExpression(t.identifier("self"), namespace), t.objectExpression([]))
    )
  ]));

  _.each(File.declarations, function (name) {
    var key = t.identifier(t.toIdentifier(name));
    body.push(t.expressionStatement(
      t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
    ));
  });

  return generator(tree).code;
};<commit_msg>turn custom runtime into a proper identifier<commit_after>var generator = require("./generation/generator");
var util      = require("./util");
var File      = require("./file");
var t         = require("./types");
var _         = require("lodash");

module.exports = function (namespace) {
  namespace = t.identifier(t.toIdentifier(namespace || "to5Runtime"));

  var body      = [];
  var container = t.functionExpression(null, [], t.blockStatement(body));
  var tree      = t.program([t.expressionStatement(t.callExpression(container, []))]);

  body.push(util.template("self-global", true));

  body.push(t.variableDeclaration("var", [
    t.variableDeclarator(
      namespace,
      t.assignmentExpression("=", t.memberExpression(t.identifier("self"), namespace), t.objectExpression([]))
    )
  ]));

  _.each(File.declarations, function (name) {
    var key = t.identifier(t.toIdentifier(name));
    body.push(t.expressionStatement(
      t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
    ));
  });

  return generator(tree).code;
};
{'fraction_non_alphanumeric': 0.17463322290582112, 'fraction_numerical': 0.000946521533364884, 'mean_word_length': 3.939252336448598, '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': '3783989', 'n_tokens_mistral': 624, 'n_tokens_neox': 609, 'n_words': 108}