Comparing version 2.2.6 to 2.3.0
@@ -219,27 +219,3 @@ /* | ||
if (opts.slow) { | ||
var slow = this._slow = { latency: 0 }; | ||
['rate', 'latency', 'up', 'down'].forEach(function (name) { | ||
var val = opts.slow[name]; | ||
if (val === undefined) { | ||
return; | ||
} | ||
if (typeof val !== 'number') { | ||
throw new Error('slow.' + name + ' must be a number'); | ||
} | ||
if (val < 0) { | ||
throw new Error('slow.' + name + ' must be >= 0'); | ||
} | ||
}); | ||
if (opts.slow.rate) { | ||
slow.rate = new _streamThrottle.ThrottleGroup({ rate: opts.slow.rate }); | ||
} | ||
if (opts.slow.latency) { | ||
slow.latency = opts.slow.latency; | ||
} | ||
if (opts.slow.up) { | ||
slow.up = new _streamThrottle.ThrottleGroup({ rate: opts.slow.up }); | ||
} | ||
if (opts.slow.down) { | ||
slow.down = new _streamThrottle.ThrottleGroup({ rate: opts.slow.down }); | ||
} | ||
this.slow(opts.slow); | ||
} | ||
@@ -524,2 +500,39 @@ | ||
}, { | ||
key: 'slow', | ||
value: function slow(opts) { | ||
if (opts) { | ||
var slow = this._slow = { opts: opts, latency: 0 }; | ||
['rate', 'latency', 'up', 'down'].forEach(function (name) { | ||
var val = opts[name]; | ||
if (val === undefined) { | ||
return; | ||
} | ||
if (typeof val !== 'number') { | ||
throw new Error('slow.' + name + ' must be a number'); | ||
} | ||
if (val < 0) { | ||
throw new Error('slow.' + name + ' must be >= 0'); | ||
} | ||
}); | ||
if (opts.rate) { | ||
slow.rate = new _streamThrottle.ThrottleGroup({ rate: opts.rate }); | ||
} | ||
if (opts.latency) { | ||
slow.latency = opts.latency; | ||
} | ||
if (opts.up) { | ||
slow.up = new _streamThrottle.ThrottleGroup({ rate: opts.up }); | ||
} | ||
if (opts.down) { | ||
slow.down = new _streamThrottle.ThrottleGroup({ rate: opts.down }); | ||
} | ||
} else { | ||
if (!this._slow) { | ||
return undefined; | ||
} else { | ||
return this._slow.opts; | ||
} | ||
} | ||
} | ||
}, { | ||
key: '_emitError', | ||
@@ -526,0 +539,0 @@ value: function _emitError(ex, phase) { |
{ | ||
"name": "hoxy", | ||
"version": "2.2.6", | ||
"version": "2.3.0", | ||
"author": "Greg Reimer <gregreimer@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Web-hacking proxy API for node", |
@@ -30,2 +30,3 @@ # Hoxy | ||
* **2.3.0** Added getter and setter for proxy-level slow options. | ||
* **2.2.6** Added eslint npm script. Thanks [@nerdbeere](https://github.com/nerdbeere). | ||
@@ -32,0 +33,0 @@ * **2.2.5** Fixed a bug where `.buffer` was always undefined. Thanks [@Timwi](https://github.com/Timwi). |
58
84472
28
2326