declare.js
function(){

          // These will be worked out from `arguments`
          var SuperCtorList, protoMixin;

          var MixedClass, ResultClass;
          var list = [];
          var i, l, ii, ll;
          var proto;


          var r = workoutDeclareArguments( arguments );
          SuperCtorList = r.SuperCtorList;
          protoMixin = r.protoMixin;

          // No parameters: inheriting from Object directly, no multiple inheritance
          if( SuperCtorList.length === 0 ){
            MixedClass = Object;
          }
          // Only one parameter: straght single inheritance.
          else if( SuperCtorList.length === 1 ){
            MixedClass = SuperCtorList[ 0 ];

          // More than one parameter: multiple inheritance at work
          // MixedClass will end up being an artificially made constructor
          // where the prototype chain is the sum of _every_ prototype in
          // every element of SuperCtorList (taking out duplicates)
          } else {
            MixedClass = Object;

            // NOW:
            // Go through every __proto__ of every derivative class, and augment
            // MixedClass by inheriting from A COPY OF each one of them.

            list = [];
            for( i = 0, l = SuperCtorList.length; i < l; i ++ ){

              // Get the prototype list, in the right order
              // (the reversed discovery order)
              // The result will be placed in `subList`
              var subList = [];
              if( typeof SuperCtorList[ i ] === 'undefined' || typeof SuperCtorList[ i ].prototype === 'undefined'){
                throw new Error("Invalid constructor!")
              }

              proto = SuperCtorList[ i ].prototype;
              while( proto ){
                if( proto.constructor !== Object ) subList.push( proto );
                proto = Object.getPrototypeOf( proto );
              }
              subList = subList.reverse();

              // Add each element of sublist as long as it's not already in the main `list`
              for( ii = 0, ll = subList.length; ii < ll; ii ++ ){
                if( ! constructorAlreadyInList( subList[ ii ].constructor, list ) ) list.push( subList[ ii ] );
              }
            }

            // For each element in the prototype list that isn't Object(),
            // augment MixedClass with a copy of the new prototype
            for( ii = 0, ll = list.length; ii < ll; ii ++ ){
              proto = list[ ii ];

              var M = MixedClass;

              if( proto.constructor !== Object ){

                MixedClass = makeConstructor( MixedClass, proto, proto.constructor );
                copyClassMethods( M, MixedClass ); // Methods previously inherited

                copyClassMethods( proto.constructor, MixedClass ); // Extra methods from the father constructor
              }
            }
          }

          // Finally, inherit from the MixedClass, and add
          // class methods over
          // MixedClass might be:
          // * Object (coming from no inheritance),
          // * SuperCtorList[0] (coming from single inheritance)
          // * A constructor with the appropriate prototype chain (multiple inheritance)
          ResultClass = makeConstructor( MixedClass, protoMixin );
          copyClassMethods( MixedClass, ResultClass );

          // Add getInherited, inherited() and inheritedAsync() to the prototype
          // (only if they are not already there)
          if( ! ResultClass.prototype.getInherited ) {
            ResultClass.prototype.getInherited = getInherited;
          }
          if( ! ResultClass.prototype.inherited ) {
            ResultClass.prototype.inherited = makeInheritedFunction( 'sync' );
          }
          if( ! ResultClass.prototype.inheritedAsync ) {
            ResultClass.prototype.inheritedAsync = makeInheritedFunction( 'async' );
          }

          // Add instanceOf
          if( ! ResultClass.prototype.instanceOf ) {
            ResultClass.prototype.instanceOf = instanceOf;
          }

          // Add class-wide method `extend`
          ResultClass.extend = function(){
            return extend.apply( this, arguments );
          };

          // That's it!
          return ResultClass;
        }
function(){

          // These will be worked out from `arguments`
          var SuperCtorList, protoMixin;

          var MixedClass, ResultClass;
          var list = [];
          var i, l, ii, ll;
          var proto;


          var r = workoutDeclareArguments( arguments );
          SuperCtorList = r.SuperCtorList;
          protoMixin = r.protoMixin;

          // No parameters: inheriting from Object directly, no multiple inheritance
          if( SuperCtorList.length === 0 ){
            MixedClass = Object;
          }
          // Only one parameter: straght single inheritance.
          else if( SuperCtorList.length === 1 ){
            MixedClass = SuperCtorList[ 0 ];

          // More than one parameter: multiple inheritance at work
          // MixedClass will end up being an artificially made constructor
          // where the prototype chain is the sum of _every_ prototype in
          // every element of SuperCtorList (taking out duplicates)
          } else {
            MixedClass = Object;

            // NOW:
            // Go through every __proto__ of every derivative class, and augment
            // MixedClass by inheriting from A COPY OF each one of them.

            list = [];
            for( i = 0, l = SuperCtorList.length; i < l; i ++ ){

              // Get the prototype list, in the right order
              // (the reversed discovery order)
              // The result will be placed in `subList`
              var subList = [];
              if( typeof SuperCtorList[ i ] === 'undefined' || typeof SuperCtorList[ i ].prototype === 'undefined'){
                throw new Error("Invalid constructor!")
              }

              proto = SuperCtorList[ i ].prototype;
              while( proto ){
                if( proto.constructor !== Object ) subList.push( proto );
                proto = Object.getPrototypeOf( proto );
              }
              subList = subList.reverse();

              // Add each element of sublist as long as it's not already in the main `list`
              for( ii = 0, ll = subList.length; ii < ll; ii ++ ){
                if( ! constructorAlreadyInList( subList[ ii ].constructor, list ) ) list.push( subList[ ii ] );
              }
            }

            // For each element in the prototype list that isn't Object(),
            // augment MixedClass with a copy of the new prototype
            for( ii = 0, ll = list.length; ii < ll; ii ++ ){
              proto = list[ ii ];

              var M = MixedClass;

              if( proto.constructor !== Object ){

                MixedClass = makeConstructor( MixedClass, proto, proto.constructor );
                copyClassMethods( M, MixedClass ); // Methods previously inherited

                copyClassMethods( proto.constructor, MixedClass ); // Extra methods from the father constructor
              }
            }
          }

          // Finally, inherit from the MixedClass, and add
          // class methods over
          // MixedClass might be:
          // * Object (coming from no inheritance),
          // * SuperCtorList[0] (coming from single inheritance)
          // * A constructor with the appropriate prototype chain (multiple inheritance)
          ResultClass = makeConstructor( MixedClass, protoMixin );
          copyClassMethods( MixedClass, ResultClass );

          // Add getInherited, inherited() and inheritedAsync() to the prototype
          // (only if they are not already there)
          if( ! ResultClass.prototype.getInherited ) {
            ResultClass.prototype.getInherited = getInherited;
          }
          if( ! ResultClass.prototype.inherited ) {
            ResultClass.prototype.inherited = makeInheritedFunction( 'sync' );
          }
          if( ! ResultClass.prototype.inheritedAsync ) {
            ResultClass.prototype.inheritedAsync = makeInheritedFunction( 'async' );
          }

          // Add instanceOf
          if( ! ResultClass.prototype.instanceOf ) {
            ResultClass.prototype.instanceOf = instanceOf;
          }

          // Add class-wide method `extend`
          ResultClass.extend = function(){
            return extend.apply( this, arguments );
          };

          // That's it!
          return ResultClass;
        }
function ( ) { // These will be worked out from `arguments` var SuperCtorList , protoMixin ; var MixedClass , ResultClass ; var list = [ ] ; var i , l , ii , ll ; var proto ; var r = workoutDeclareArguments ( arguments ) ; SuperCtorList = r . SuperCtorList ; protoMixin = r . protoMixin ; // No parameters: inheriting from Object directly, no multiple inheritance if ( SuperCtorList . length === 0 ) { MixedClass = Object ; } // Only one parameter: straght single inheritance. else if ( SuperCtorList . length === 1 ) { MixedClass = SuperCtorList [ 0 ] ; // More than one parameter: multiple inheritance at work // MixedClass will end up being an artificially made constructor // where the prototype chain is the sum of _every_ prototype in // every element of SuperCtorList (taking out duplicates) } else { MixedClass = Object ; // NOW: // Go through every __proto__ of every derivative class, and augment // MixedClass by inheriting from A COPY OF each one of them. list = [ ] ; for ( i = 0 , l = SuperCtorList . length ; i < l ; i ++ ) { // Get the prototype list, in the right order // (the reversed discovery order) // The result will be placed in `subList` var subList = [ ] ; if ( typeof SuperCtorList [ i ] === 'undefined' || typeof SuperCtorList [ i ] . prototype === 'undefined' ) { throw new Error ( "Invalid constructor!" ) } proto = SuperCtorList [ i ] . prototype ; while ( proto ) { if ( proto . constructor !== Object ) subList . push ( proto ) ; proto = Object . getPrototypeOf ( proto ) ; } subList = subList . reverse ( ) ; // Add each element of sublist as long as it's not already in the main `list` for ( ii = 0 , ll = subList . length ; ii < ll ; ii ++ ) { if ( ! constructorAlreadyInList ( subList [ ii ] . constructor , list ) ) list . push ( subList [ ii ] ) ; } } // For each element in the prototype list that isn't Object(), // augment MixedClass with a copy of the new prototype for ( ii = 0 , ll = list . length ; ii < ll ; ii ++ ) { proto = list [ ii ] ; var M = MixedClass ; if ( proto . constructor !== Object ) { MixedClass = makeConstructor ( MixedClass , proto , proto . constructor ) ; copyClassMethods ( M , MixedClass ) ; // Methods previously inherited copyClassMethods ( proto . constructor , MixedClass ) ; // Extra methods from the father constructor } } } // Finally, inherit from the MixedClass, and add // class methods over // MixedClass might be: // * Object (coming from no inheritance), // * SuperCtorList[0] (coming from single inheritance) // * A constructor with the appropriate prototype chain (multiple inheritance) ResultClass = makeConstructor ( MixedClass , protoMixin ) ; copyClassMethods ( MixedClass , ResultClass ) ; // Add getInherited, inherited() and inheritedAsync() to the prototype // (only if they are not already there) if ( ! ResultClass . prototype . getInherited ) { ResultClass . prototype . getInherited = getInherited ; } if ( ! ResultClass . prototype . inherited ) { ResultClass . prototype . inherited = makeInheritedFunction ( 'sync' ) ; } if ( ! ResultClass . prototype . inheritedAsync ) { ResultClass . prototype . inheritedAsync = makeInheritedFunction ( 'async' ) ; } // Add instanceOf if ( ! ResultClass . prototype . instanceOf ) { ResultClass . prototype . instanceOf = instanceOf ; } // Add class-wide method `extend` ResultClass . extend = function ( ) { return extend . apply ( this , arguments ) ; } ; // That's it! return ResultClass ; }
Parameters are very variable
Parameters are very variable