<commit_before>var hasOwn = require("mout/object/hasOwn");
var create = require("mout/lang/createObject");

Function.prototype.static = function(){
  this.$static = true;
  return this;
}

//from http://javascript.crockford.com/prototypal.html

var verbs = /^initialize|Implements|Extends$/

var implement = function(obj){
  for(var key in obj) {
    if (key.match(verbs)) continue;

    if((typeof obj[key] == 'function') && obj[key].$static)
      this[key] = obj[key];
    else
      this.prototype[key] = obj[key];
  }

  return this;
}



var uClass = function(proto){

  var superprime = proto.Extends;

  var constructor = (hasOwn(proto, "initialize")) ? proto.initialize : (superprime) ? function(){
        return superprime.apply(this, arguments)
    } : function(){};

  var out = function() {
      //autobinding takes place here
    if(proto.Binds) proto.Binds.forEach(function(f){
      var original = this[f];
      if(original) this[f] = original.bind(this);
    }, this);

    constructor.apply(this, arguments);
  }

  out.implements = implement;

  if(proto.Implements)
    proto.Implements.forEach(function(Mixin){
      out.implements(new Mixin);
    });

  if (superprime) {
    // inherit from superprime
      var superproto = superprime.prototype;
      var cproto = out.prototype = create(superproto);
      // setting constructor.parent to superprime.prototype
      // because it's the shortest possible absolute reference
      out.parent = superproto;
      cproto.constructor = out
  }

  out.implements(proto);

  return out;
};



module.exports = uClass;<commit_msg>Specs/tests alignment<commit_after>var hasOwn = require("mout/object/hasOwn");
var create = require("mout/lang/createObject");
var kindOf = require("mout/lang/kindOf");


Function.prototype.static = function(){
  this.$static = true;
  return this;
}

//from http://javascript.crockford.com/prototypal.html

var verbs = /^initialize|Implements|Extends$/

var implement = function(obj){
  for(var key in obj) {
    //if (key.match(verbs)) continue;

    if((typeof obj[key] == 'function') && obj[key].$static)
      this[key] = obj[key];
    else
      this.prototype[key] = obj[key];
  }

  return this;
}



var uClass = function(proto){

  if (kindOf(proto) === "Function") proto = {initialize: proto};

  var superprime = proto.Extends;

  var constructor = (hasOwn(proto, "initialize")) ? proto.initialize : (superprime) ? function(){
        return superprime.apply(this, arguments)
    } : function(){};


  var out = function() {
      //autobinding takes place here
    if(proto.Binds) proto.Binds.forEach(function(f){
      var original = this[f];
      if(original) this[f] = original.bind(this);
    }, this);

    constructor.apply(this, arguments);
  }

  out.implement = implement;


  if (superprime) {
    // inherit from superprime
      var superproto = superprime.prototype;
      var cproto = out.prototype = create(superproto);
      // setting constructor.parent to superprime.prototype
      // because it's the shortest possible absolute reference
      out.parent = superproto;
      cproto.constructor = out
  }

  if(proto.Implements) {

    if (kindOf(proto.Implements) !== "Array")
      proto.Implements = [proto.Implements];
    proto.Implements.forEach(function(Mixin){
      out.implement(new Mixin);
    });
  }
  out.implement(proto);

  return out;
};



module.exports = uClass;
{'fraction_non_alphanumeric': 0.14202049780380674, 'fraction_numerical': 0.0, 'mean_word_length': 3.3076923076923075, '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': '279975', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1046, 'n_words': 236}