nl_tokens: 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 .
pl_tokens: 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 , <mask> ] ; // 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 ; }