Skip to content

Instantly share code, notes, and snippets.

@adsurbum
Created July 4, 2017 17:51
Show Gist options
  • Save adsurbum/b3169fb002af6dd66e9fc9ec5b98aafb to your computer and use it in GitHub Desktop.
Save adsurbum/b3169fb002af6dd66e9fc9ec5b98aafb to your computer and use it in GitHub Desktop.
/**
* 1 req per 30 ms.
*/
const express = require('express')
const app = express()
const resArray = new Array();
function rec(){
const firstInQueue = resArray.shift();
if (firstInQueue)
firstInQueue.send('Hello World');
setTimeout(rec, 30);
}
app.get('/', function (req, res) {
resArray.push(res);
})
app.get('/quick', function (req, res) {
res.send('Hello World');
})
app.listen(3000, function () {
rec()
console.log('Example app listening on port 3000!')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment