express-delay
Advanced tools
Comparing version 0.0.1 to 0.1.0
var timers = require('timers'); | ||
var create_delayer = function(time) { | ||
var get_random_int = function(min, max) { | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} | ||
var create_delayer = function(min, max) { | ||
var useRandomDelay = (arguments.length === 2); | ||
return function(req, res, next) { | ||
var send = res.send; | ||
var time = useRandomDelay ? get_random_int(min, max) : min; | ||
@@ -7,0 +14,0 @@ res.send = function() { |
{ | ||
"name": "express-delay", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Delay express responses", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,3 +8,3 @@ express-delay | ||
You want to test your fancy ajax loaders, spinners and stuff, but your dev machine is to damn fast for that shit! | ||
You want to test your fancy ajax loaders, spinners and stuff, but your dev machine is too damn fast for that shit! | ||
@@ -28,3 +28,12 @@ ## Usage | ||
### Random delay | ||
You can also give it a range of values, which will make the delay random: | ||
```javascript | ||
// Delay will be between 200 and 500 milliseconds | ||
app.use(delay(200, 500)); | ||
``` | ||
## LICENSE | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1795
19
38