-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrouble.js
More file actions
44 lines (39 loc) · 803 Bytes
/
trouble.js
File metadata and controls
44 lines (39 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
function Message(s) {
this.value = s;
}
Message.prototype.toString = function () {
return this.value + '<!-- padding ' + new Array(2048).join(' ') + '-->';
};
module.exports = {
one: function one(res) {
var ctr = 0;
var m;
while (true) {
ctr++;
m = new Message('.\n');
res.write(m.toString());
}
res.end();
},
two: function two(res) {
var ctr = 100;
setInterval(function () {
ctr--;
var m = new Message((100 - ctr) + '\n');
res.write(m.toString());
}, 200);
setTimeout(function () {
res.end();
}, (200 * 100) + 201);
},
three: function three(res) {
var ctr = 100;
var m;
while (ctr--) {
m = new Message('.\n');
res.write(m.toString());
}
res.end();
},
};