<commit_before>/**
 * Dependencies
 */
var _ = require('lodash');
var InternalUtils = require('../internal-utils');

/***********************************************************************************************************************
 * The purpose of this module is to provide a clear object model for OOJS programming. This is a base Class
 * implementation using the factory pattern. An implementation of 'super' inspired by John Resig is also available to
 * make this object model more scalable.
 *
 * ### Create a class
 *
 * ``` javascript
 * var Person = NOOT.Object.extend({
 *   firstName: '',
 *   lastName: '',
 *
 *   init: function() {
 *     if(!this.lastName || !this.firstName) throw new Error('<NAME> is a myth');
 *   },
 *
 *   sayHello: function() {
 *     console.log('Hello, my name is', this.getFullName());
 *   },
 *
 *   getFullName: function() {
 *     return this.firstName + ' ' + this.lastName;
 *   }
 * });
 *
 *
 * var person = Person.create({
 *   firstName: 'John',
 *   lastName: 'Doe'
 * });
 *
 * person.sayHello();
 * // Hello, my name is <NAME>
 * ```
 *
 * ### Extend a class
 *
 * ``` javascript
 * var Employee = Person.extend({
 *   job: '',
 *
 *   sayHello: function() {
 *     console.log(this._super(), ', I work as a ', this.job);
 *   }
 * });
 *
 *
 * var employee = Employee.create({
 *   firstName: 'John',
 *   lastName: 'Doe',
 *   job: 'developer'
 * });
 *
 * employee.sayHello();
 * // Hello, my name is <NAME>, I work as a developer
 * ```
 *
 * @class Object
 * @constructor
 **********************************************************************************************************************/
var Obj = function () { };

/**
 * Extend
 *
 * @method extend
 * @static
 * @param {Object} [prototype] Instance members
 * @param {Object} [statics] Static members
 */
Obj.extend = function (prototype, statics) {
  if (!arguments.length) prototype = {};
  statics = statics || {};

  // Constructor
  var child = function () { return this; };
  var proto = {};

  // 'super' implementation
  InternalUtils.buildSuper(proto, this.prototype, prototype);

  // Prototypal inheritance
  var Surrogate = function () { this.constructor = child; };
  Surrogate.prototype = this.prototype;

  // Static properties
  var stat = {};
  InternalUtils.buildSuper(stat, this, statics);
  _.extend(child, this, stat);

  child.protos = new Surrogate();
  for (var key in proto) {
    child.prototype[key] = proto[key];
  }

  // Return the newly created class
  return child;
};


/**
 * @method create
 * @static
 * @param {Object} [def]
 */
Obj.create = function(def) {
  var instance = new this.prototype.constructor();

  // Set instance members
  for (var key in def) {
    instance[key] = def[key];
  }
  // Call 'init' method, it acts as a constructor
  instance.init.call(instance);
  return instance;
};

/**
 * @exports
 */
module.exports = Obj.extend({
  init: function() { return this; }
});<commit_msg>Fixed variable name in NOOT.CoreObject<commit_after>/**
 * Dependencies
 */
var _ = require('lodash');
var InternalUtils = require('../internal-utils');

/***********************************************************************************************************************
 * The purpose of this module is to provide a clear object model for OOJS programming. This is a base Class
 * implementation using the factory pattern. An implementation of 'super' inspired by John Resig is also available to
 * make this object model more scalable.
 *
 * ### Create a class
 *
 * ``` javascript
 * var Person = NOOT.Object.extend({
 *   firstName: '',
 *   lastName: '',
 *
 *   init: function() {
 *     if(!this.lastName || !this.firstName) throw new Error('<NAME> is a myth');
 *   },
 *
 *   sayHello: function() {
 *     console.log('Hello, my name is', this.getFullName());
 *   },
 *
 *   getFullName: function() {
 *     return this.firstName + ' ' + this.lastName;
 *   }
 * });
 *
 *
 * var person = Person.create({
 *   firstName: 'John',
 *   lastName: 'Doe'
 * });
 *
 * person.sayHello();
 * // Hello, my name is <NAME>
 * ```
 *
 * ### Extend a class
 *
 * ``` javascript
 * var Employee = Person.extend({
 *   job: '',
 *
 *   sayHello: function() {
 *     console.log(this._super(), ', I work as a ', this.job);
 *   }
 * });
 *
 *
 * var employee = Employee.create({
 *   firstName: 'John',
 *   lastName: 'Doe',
 *   job: 'developer'
 * });
 *
 * employee.sayHello();
 * // Hello, my name is <NAME>, I work as a developer
 * ```
 *
 * @class Object
 * @constructor
 **********************************************************************************************************************/
var Obj = function () { };

/**
 * Extend
 *
 * @method extend
 * @static
 * @param {Object} [prototype] Instance members
 * @param {Object} [statics] Static members
 */
Obj.extend = function (prototype, statics) {
  if (!arguments.length) prototype = {};
  statics = statics || {};

  // Constructor
  var child = function () { return this; };
  var proto = {};

  // 'super' implementation
  InternalUtils.buildSuper(proto, this.prototype, prototype);

  // Prototypal inheritance
  var Surrogate = function () { this.constructor = child; };
  Surrogate.prototype = this.prototype;

  // Static properties
  var stat = {};
  InternalUtils.buildSuper(stat, this, statics);
  _.extend(child, this, stat);

  child.prototype = new Surrogate();
  for (var key in proto) {
    child.prototype[key] = proto[key];
  }

  // Return the newly created class
  return child;
};


/**
 * @method create
 * @static
 * @param {Object} [def]
 */
Obj.create = function(def) {
  var instance = new this.prototype.constructor();

  // Set instance members
  for (var key in def) {
    instance[key] = def[key];
  }
  // Call 'init' method, it acts as a constructor
  instance.init.call(instance);
  return instance;
};

/**
 * @exports
 */
module.exports = Obj.extend({ init: function() { return this; } });
{'fraction_non_alphanumeric': 0.23269489247311828, 'fraction_numerical': 0.0, 'mean_word_length': 3.396602658788774, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5596861', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1742, 'n_words': 500}