code: function proxy (frontend, backend, capture){
    switch(frontend.type+'/'+backend.type){
      case 'push/pull':
      case 'pull/push':
      case 'xpub/xsub':
        if(capture){
  
          frontend.on('message',function (){
            backend.send([].slice.call(arguments));
          });
  
          backend.on('message',function (){
            frontend.send([].slice.call(arguments));
  
            //forwarding messages over capture socket
            capture.send([].slice.call(arguments));
          });
  
        } else {
  
          //no capture socket provided, just forwarding msgs to respective sockets
          frontend.on('message',function (){
            backend.send([].slice.call(arguments));
          });
  
          backend.on('message',function (){
            frontend.send([].slice.call(arguments));
          });
  
        }
        break;
      case 'router/dealer':
      case 'xrep/xreq':
        if(capture){
  
          //forwarding router/dealer pack signature: id, delimiter, msg
          frontend.on('message',function (id,delimiter,msg){
            backend.send([].slice.call(arguments));
          });
  
          backend.on('message',function (id,delimiter,msg){
            frontend.send([].slice.call(arguments));
  
            //forwarding message to the capture socket
            capture.send([].slice.call(arguments, 2));
          });
  
        } else {
  
          //forwarding router/dealer signatures without capture
          frontend.on('message',function (id,delimiter,msg){
            backend.send([].slice.call(arguments));
          });
  
          backend.on('message',function (id,delimiter,msg){
            frontend.send([].slice.call(arguments));
          });
  
        }
        break;
      default:
        throw new Error('wrong socket order to proxy');
    }
  }
docs: JS based on API characteristics of the native zmq_proxy()