mixin.js
function mixin(base, mixin) {
  var ctor = base;
  if (base.constructors) {
    // Don't mixin the same constructor if already mixed.
    if(subOf(base, mixin)) return base;
    // Remember this new one.
    base.constructors.unshift(mixin);

  } else {
    // Remember all mixed in classes
    base.constructors = [mixin, base];
    // Create a function with the same name, that calls all inherited constructors ...
    ctor = base.prototype.constructor = mixin_constructor(base.name, base);
    ctor.__proto__ = base;
  }

  // Inject the mixin prototype at the top of the chain
  ctor.prototype = insert_proto(base.prototype, mixin.prototype);
  //inspect_protos(ctor.prototype, "ctor.prototype");

  insert_proto(ctor.__proto__, mixin);
  //inspect_protos(ctor, "ctor");

  // Inform mixin that it has been included
  if (mixin.hasOwnProperty('included')) {
    var incl = mixin.included.call(mixin, ctor);
    if (incl) { ctor = incl; }
  }

  return ctor;
}
function mixin(base, mixin) {
  var ctor = base;
  if (base.constructors) {
    // Don't mixin the same constructor if already mixed.
    if(subOf(base, mixin)) return base;
    // Remember this new one.
    base.constructors.unshift(mixin);

  } else {
    // Remember all mixed in classes
    base.constructors = [mixin, base];
    // Create a function with the same name, that calls all inherited constructors ...
    ctor = base.prototype.constructor = mixin_constructor(base.name, base);
    ctor.__proto__ = base;
  }

  // Inject the mixin prototype at the top of the chain
  ctor.prototype = insert_proto(base.prototype, mixin.prototype);
  //inspect_protos(ctor.prototype, "ctor.prototype");

  insert_proto(ctor.__proto__, mixin);
  //inspect_protos(ctor, "ctor");

  // Inform mixin that it has been included
  if (mixin.hasOwnProperty('included')) {
    var incl = mixin.included.call(mixin, ctor);
    if (incl) { ctor = incl; }
  }

  return ctor;
}
Mix the {mixin} constructor into the {base} constructor.  Ensures that the
all properties of {mixin} are available in {ctor} both for the constructor
and its prototype.

The following are guaranteed consequences of the mixin:
* Will not mixin the same constructor twice.
* More than one constructor may be mixed in to the same {base}.
* Invokes the function {mixin.included(base)} after the mixin, if it is defined.
* {new ctor(...)} will invoke the constructors of all mixed in constructors and
the original constructor in reverse order of their being mixed in.
* Properties of the {base} constructor and all previous mixins have priority over
those of the {mixin}.

@param {Function} base  The constructor that {mixin} will be added to.
@param {Function} mixin The constructor that will be mixed in to {base}.