'use strict';

var net = require('net');
var Throttle = require('stream-throttle');

module.exports = function(grunt) {

  grunt.registerMultiTask('throttle', 'Grunt plugin for testing under a throttled connection.', function() {

    var self = this;

    var server = net.createServer(function (local) {
      var remote = net.createConnection({host: self.data.remote_host, port: self.data.remote_port});

      var localThrottle = new Throttle({rate: self.data.upstream});
      var remoteThrottle = new Throttle({rate: self.data.downstream});

      local.pipe(localThrottle).pipe(remote);
      remote.pipe(remoteThrottle).pipe(local);
    });

    server.listen(this.data.local_port);
  });

};

@@ -46,16 +46,21 @@
 Throttle
+Group
  = requi
@@ -80,16 +80,30 @@
 rottle')
+.ThrottleGroup
 ;%0A%0Amodul
@@ -265,16 +265,157 @@
  this;%0A%0A
+    var upThrottle = new ThrottleGroup(%7Brate: self.data.upstream%7D);%0A    var downThrottle = new ThrottleGroup(%7Brate: self.data.downstream%7D);%0A%0A
     var 
@@ -583,36 +583,34 @@
 lThrottle = 
-new 
+up
 Throttle
 (%7Brate: self
@@ -601,35 +601,18 @@
 ttle
-(%7Brate: self.data.upstream%7D
+.throttle(
 );%0A 
@@ -637,28 +637,28 @@
 ottle = 
-new 
+down
 Throttle
 (%7Brate: 
@@ -653,37 +653,18 @@
 ttle
-(%7Brate: self.data.downstream%7D
+.throttle(
 );%0A%0A

Use ThrottleGroup