<commit_before>/*  Mod.js - v0.1.0
 *  Copyright 2012, <NAME>
 *  Released under the MIT license
 *  More Information: http://github.com/aron/mod.js
 */
(function (context) {
  var _module = context.module;

  /* Public: Returns the object under the provided namespace, if it does
   * not exist then creates one. The value of the object cab also be set
   * via the second argument. This will take a basic value or a factory
   * function that should then return the actual value.
   *
   * keypath - The keypath for the module to return.
   * value   - The value to set the module to.
   *
   * Examples
   *
   *   // Get a module.
   *   module('app.views.list'); //=> {}
   *
   *   // Create a module.
   *   module('app.config', {setting: 'a'});
   *   module('app.config'); //=> {setting: 'a'}
   *
   *   // Create a module with a function. Extra arguments are passed into
   *   // the factory function.
   *   module('app.views.list, function ($, window, undefined) {
   *     return function ListView() {};
   *   }, jQuery, window);
   *
   * Returns the module if called with a single argument otherwise returns
   * the module() function.
   */
  function module(keypath, properties) {
    var object = module.modules,
        keys = (keypath || '').split(module.options.delimiter),
        key, previous;

    while (object && keys.length && keys[0]) {
      key = keys.shift();

      previous = object;
      if (object.hasOwnProperty(key)) {
        object = object[key];

        if (keys.length === 0 && object !== undefined) {
          break;
        }
      } else {
        object = object[key] = {};
      }
    }

    if (properties) {
      if (typeof properties === 'function') {
        properties = module.run(properties, [].slice.call(arguments, 2));
      }

      if (module.isObject(properties)) {
        module.extend(object, properties);
      } else {
        previous[key] = properties;
      }
      return module;
    }

    return object;
  }

  /* Helper function that calls the factory function with the correct context
   * and arguments and returns the result.
   *
   * fn   - The function to be called.
   * args - The intial arguments to call the function with.
   *
   * Returns the result of the function call.
   */
  module.run = function (fn, args) {
    args = args.concat(module.options.arguments);
    return fn.apply(module.options.context, args);
  };

  /* Checks to see whether the object passed is an object literal.
   *
   * object - The object to test.
   *
   * Examples
   *
   *   module.isObject({});     // true
   *   module.isObject([]);     // false
   *   module.isObject(window); // false
   *<commit_msg>Rename module() arguments for clarity<commit_after>/*  Mod.js - v0.1.0
 *  Copyright 2012, <NAME>
 *  Released under the MIT license
 *  More Information: http://github.com/aron/mod.js
 */
(function (context) {
  var _module = context.module;

  /* Public: Returns the object under the provided namespace, if it does
   * not exist then creates one.
   *
   * The value of the object can also be set by passing the value argument.
   * This can take a basic value or a factory function that should then return
   * the actual value to be used.
   *
   * Additional arguments passed into the function will be provided as
   * arguments to the factory function. This can be used in the same way as
   * you would a wrapping a script in a closure e.g. passing in jQuery to
   * create the $ shorthand.
   *
   * keypath - The keypath for the module to return.
   * value   - The value to set the module to.
   *
   * Examples
   *
   *   // Get a module.
   *   module('app.views.list'); //=> {}
   *
   *   // Create a module.
   *   module('app.config', {setting: 'a'});
   *   module('app.config'); //=> {setting: 'a'}
   *
   *   // Create a module with a function. Extra arguments are passed into
   *   // the factory function.
   *   module('app.views.list, function ($, window, undefined) {
   *     return function ListView() {};
   *   }, jQuery, window);
   *
   * Returns the module if called with a single argument otherwise returns
   * the module() function.
   */
  function module(keypath, value) {
    var object = module.modules,
        keys = (keypath || '').split(module.options.delimiter),
        key, previous;

    while (object && keys.length && keys[0]) {
      key = keys.shift();

      previous = object;
      if (object.hasOwnProperty(key)) {
        object = object[key];

        if (keys.length === 0 && object !== undefined) {
          break;
        }
      } else {
        object = object[key] = {};
      }
    }

    if (value) {
      if (typeof value === 'function') {
        value = module.run(value, [].slice.call(arguments, 2));
      }

      if (module.isObject(value)) {
        module.extend(object, value);
      } else {
        previous[key] = value;
      }
      return module;
    }

    return object;
  }

  /* Helper function that calls the factory function with the correct context
   * and arguments and returns the result.
   *
   * fn   - The function to be called.
   * args - The intial arguments to call the function with.
   *
   * Returns the result of the function call.
   */
  module.run = function (fn, args) {
    args = args.concat(module.options.arguments);
    return fn.apply(module.options.context, args);
  };

  /* Checks to see whether the object passed is an object literal.
   *
   * object - The object to test.
   *
   * Examples
   *
   *   module.isObject({});     // true
   *   module.isObject([]);     // false
   *   module.isObject(window); // false
   *
{'fraction_non_alphanumeric': 0.12333392571530123, 'fraction_numerical': 0.003554291807357384, 'mean_word_length': 2.2438040345821326, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5634943', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1635, 'n_words': 561}