function generateProxyMethod( pluginObject, methodFunction ) {
  function ProxyMethod() {
    // was this function invoked with the "new" keyword?
    if ( this instanceof ProxyMethod ) {
      // replace the current context with the desired one!
      var _this = Object.create( methodFunction.prototype );
      methodFunction.apply( _this, arguments );
      return _this;

    } else {
      // preserve the plugin method's original context
      return methodFunction.apply( pluginObject, arguments );
    }
  }
  return ProxyMethod;
}
/**
 * Generate a function which proxies the given method, intelligently passing
 * either the plugin object or the newly-constructed object, depending on
 * whether or not the returned function was invoked with the "new" keyword.
 * @arg  {Object}  pluginObject
 * @arg  {Function}  methodFunction
 * @return  {Function}
 */
Generate a function which proxies the given method, intelligently passing
either the plugin object or the newly-constructed object, depending on
whether or not the returned function was invoked with the "new" keyword.
@arg  {Object}  pluginObject
@arg  {Function}  methodFunction
@return  {Function}
Generate a function which proxies the given method intelligently passing either the plugin object or the newly - constructed object depending on whether or not the returned function was invoked with the " new " keyword . @arg { Object } pluginObject @arg { Function } methodFunction @return { Function }
function generateProxyMethod( pluginObject, methodFunction ) {
  function ProxyMethod() {
    if ( this instanceof ProxyMethod ) {
      var _this = Object.create( methodFunction.prototype );
      methodFunction.apply( _this, arguments );
      return _this;
    } else {
      return methodFunction.apply( pluginObject, arguments );
    }
  }
  return ProxyMethod;
}
function generateProxyMethod ( pluginObject , methodFunction ) { function ProxyMethod ( ) { if ( this instanceof ProxyMethod ) { var _this = Object . create ( methodFunction . prototype ) ; methodFunction . apply ( _this , arguments ) ; return _this ; } else { return methodFunction . apply ( pluginObject , arguments ) ; } } return ProxyMethod ; }
Generate a function which proxies the given method, intelligently passing
 either the plugin object or the newly-constructed object, depending on
 whether or not the returned function was invoked with the "new" keyword.
Generate a function which proxies the given method intelligently passing either the plugin object or the newly - constructed object depending on whether or not the returned function was invoked with the " new " keyword .
// was this function invoked with the "new" keyword? // replace the current context with the desired one! // preserve the plugin method's original context