docs: function factory( name, parentName, decorator, cfg ){
  
          var instance
              ,result
              ,parent = proto
              ,tmp
              ;
  
          // set parent if specified
          if ( typeof parentName !== 'string' ){
  
              // ... otherwise reassign parameters
              cfg = decorator;
              decorator = parentName;
  
          } else {
  
              // extend the specified module
              parent = registry[ parentName ];
  
              if ( !parent ){
  
                  throw 'Error: "' + parentName + '" ' + type + ' not defined';
              }
  
              parent = parent.prototype;
          }
  
          if ( typeof decorator === 'function' ){
  
              result = registry[ name ];
  
              if ( result ){
  
                  result.prototype = extend(result.prototype, decorator( getProto(result.prototype) ));
  
              } else {
                  // newly defined
                  // store the new class
                  result = registry[ name ] = function constructor( opts ){
                      if (this.init){
                          this.init( opts );
                      }
                  };
  
                  result.prototype = objectCreate( parent );
                  result.prototype = extend(result.prototype, decorator( parent, result.prototype ));
              }
  
              result.prototype.type = type;
              result.prototype.name = name;
  
          } else {
  
              cfg = decorator || {};
              result = registry[ name ];
              if (!result){
  
                  throw 'Error: "' + name + '" ' + type + ' not defined';
              }
          }
  
          if ( cfg ) {
  
              // create a new instance from the provided decorator
              return new result( cfg );
          }
      }