documentation/api/weaver.js-1.0.0-pre/weaver.js
function( fn ){
    var req;
    var fnName;

    if( $$.is.object(fn) && fn.fn ){ // manual fn
      req = fnAs( fn.fn, fn.name );
      fnName = fn.name;
      fn = fn.fn;
    } else if( $$.is.fn(fn) ){ // auto fn
      req = fn.toString();
      fnName = fn.name;
    } else if( $$.is.string(fn) ){ // stringified fn
      req = fn;
    } else if( $$.is.object(fn) ){ // plain object
      if( fn.proto ){
        req = '';
      } else {
        req = fn.name + ' = {};';
      }

      fnName = fn.name;
      fn = fn.obj;
    }

    req += '\n';

    var protoreq = function( val, subname ){
      if( val.prototype ){
        var protoNonempty = false;
        for( var prop in val.prototype ){ protoNonempty = true; break; };

        if( protoNonempty ){
          req += fnAsRequire( {
            name: subname,
            obj: val,
            proto: true
          }, val );
        }
      }
    };

    // pull in prototype
    if( fn.prototype && fnName != null ){

      for( var name in fn.prototype ){
        var protoStr = '';

        var val = fn.prototype[ name ];
        var valStr = stringifyFieldVal( val );
        var subname = fnName + '.prototype.' + name;

        protoStr += subname + ' = ' + valStr + ';\n';

        if( protoStr ){
          req += protoStr;
        }

        protoreq( val, subname ); // subobject with prototype
      }
  
    }

    // pull in properties for obj/fns
    if( !$$.is.string(fn) ){ for( var name in fn ){
      var propsStr = '';

      if( fn.hasOwnProperty(name) ){
        var val = fn[ name ];
        var valStr = stringifyFieldVal( val );
        var subname = fnName + '["' + name + '"]';

        propsStr += subname + ' = ' + valStr + ';\n';
      }

      if( propsStr ){
        req += propsStr;
      }

      protoreq( val, subname ); // subobject with prototype
    } }

    return req;
  }
function( fn ){
    var req;
    var fnName;

    if( $$.is.object(fn) && fn.fn ){ // manual fn
      req = fnAs( fn.fn, fn.name );
      fnName = fn.name;
      fn = fn.fn;
    } else if( $$.is.fn(fn) ){ // auto fn
      req = fn.toString();
      fnName = fn.name;
    } else if( $$.is.string(fn) ){ // stringified fn
      req = fn;
    } else if( $$.is.object(fn) ){ // plain object
      if( fn.proto ){
        req = '';
      } else {
        req = fn.name + ' = {};';
      }

      fnName = fn.name;
      fn = fn.obj;
    }

    req += '\n';

    var protoreq = function( val, subname ){
      if( val.prototype ){
        var protoNonempty = false;
        for( var prop in val.prototype ){ protoNonempty = true; break; };

        if( protoNonempty ){
          req += fnAsRequire( {
            name: subname,
            obj: val,
            proto: true
          }, val );
        }
      }
    };

    // pull in prototype
    if( fn.prototype && fnName != null ){

      for( var name in fn.prototype ){
        var protoStr = '';

        var val = fn.prototype[ name ];
        var valStr = stringifyFieldVal( val );
        var subname = fnName + '.prototype.' + name;

        protoStr += subname + ' = ' + valStr + ';\n';

        if( protoStr ){
          req += protoStr;
        }

        protoreq( val, subname ); // subobject with prototype
      }
  
    }

    // pull in properties for obj/fns
    if( !$$.is.string(fn) ){ for( var name in fn ){
      var propsStr = '';

      if( fn.hasOwnProperty(name) ){
        var val = fn[ name ];
        var valStr = stringifyFieldVal( val );
        var subname = fnName + '["' + name + '"]';

        propsStr += subname + ' = ' + valStr + ';\n';
      }

      if( propsStr ){
        req += propsStr;
      }

      protoreq( val, subname ); // subobject with prototype
    } }

    return req;
  }
function ( fn ) { var req ; var fnName ; if ( $$ . is . object ( fn ) && fn . fn ) { // manual fn req = fnAs ( fn . fn , fn . name ) ; fnName = fn . name ; fn = fn . fn ; } else if ( $$ . is . fn ( fn ) ) { // auto fn req = fn . toString ( ) ; fnName = fn . name ; } else if ( $$ . is . string ( fn ) ) { // stringified fn req = fn ; } else if ( $$ . is . object ( fn ) ) { // plain object if ( fn . proto ) { req = '' ; } else { req = fn . name + ' = {};' ; } fnName = fn . name ; fn = fn . obj ; } req += '\n' ; var protoreq = function ( val , subname ) { if ( val . prototype ) { var protoNonempty = false ; for ( var prop in val . prototype ) { protoNonempty = true ; break ; } ; if ( protoNonempty ) { req += fnAsRequire ( { name : subname , obj : val , proto : true } , val ) ; } } } ; // pull in prototype if ( fn . prototype && fnName != null ) { for ( var name in fn . prototype ) { var protoStr = '' ; var val = fn . prototype [ name ] ; var valStr = stringifyFieldVal ( val ) ; var subname = fnName + '.prototype.' + name ; protoStr += subname + ' = ' + valStr + ';\n' ; if ( protoStr ) { req += protoStr ; } protoreq ( val , subname ) ; // subobject with prototype } } // pull in properties for obj/fns if ( ! $$ . is . string ( fn ) ) { for ( var name in fn ) { var propsStr = '' ; if ( fn . hasOwnProperty ( name ) ) { var val = fn [ name ] ; var valStr = stringifyFieldVal ( val ) ; var subname = fnName + '["' + name + '"]' ; propsStr += subname + ' = ' + valStr + ';\n' ; } if ( propsStr ) { req += propsStr ; } protoreq ( val , subname ) ; // subobject with prototype } } return req ; }
allows for requires with prototypes and subobjs etc
allows for requires with prototypes and subobjs etc