This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
336 lines
9.5 KiB
336 lines
9.5 KiB
<!doctype html> |
|
<html lang="en"> |
|
<head> |
|
<title>Code coverage report for lib/writable_streambuffer.js</title> |
|
<meta charset="utf-8"> |
|
<link rel="stylesheet" href="../prettify.css"> |
|
<link rel="stylesheet" href="../base.css"> |
|
<style type='text/css'> |
|
div.coverage-summary .sorter { |
|
background-image: url(../sort-arrow-sprite.png); |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="header high"> |
|
<h1>Code coverage report for <span class="entity">lib/writable_streambuffer.js</span></h1> |
|
<h2> |
|
Statements: <span class="metric">96.77% <small>(60 / 62)</small></span> |
|
Branches: <span class="metric">90.63% <small>(29 / 32)</small></span> |
|
Functions: <span class="metric">100% <small>(9 / 9)</small></span> |
|
Lines: <span class="metric">98.25% <small>(56 / 57)</small></span> |
|
Ignored: <span class="metric"><span class="ignore-none">none</span></span> |
|
</h2> |
|
<div class="path"><a href="../index.html">All files</a> » <a href="index.html">lib/</a> » writable_streambuffer.js</div> |
|
</div> |
|
<div class="body"> |
|
<pre><table class="coverage"> |
|
<tr><td class="line-count">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 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98</td><td class="line-coverage"><span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">5</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">5</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-no"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">8</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">7</span> |
|
<span class="cline-any cline-yes">7</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">7</span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">7</span> |
|
<span class="cline-any cline-yes">7</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">11</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-yes">2</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">8</span> |
|
<span class="cline-any cline-yes">8</span> |
|
<span class="cline-any cline-yes">8</span> |
|
<span class="cline-any cline-yes">8</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">10</span> |
|
<span class="cline-any cline-yes">4</span> |
|
<span class="cline-any cline-yes">4</span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-neutral"> </span> |
|
<span class="cline-any cline-yes">1</span> |
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var util = require("util"), |
|
stream = require("stream"), |
|
constants = require("./constants"); |
|
|
|
// TODO: clear up specs on returning false from a write and emitting a drain event. |
|
// Does this mean if I return false from a write, I should ignore any write requests between that false return and the drain event? |
|
var WritableStreamBuffer = module.exports = function(opts) { |
|
var that = this; |
|
|
|
stream.Stream.call(this); |
|
|
|
opts = opts || {}; |
|
var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE; |
|
var incrementAmount = opts.incrementAmount || constants.DEFAULT_INCREMENT_AMOUNT; |
|
|
|
var buffer = new Buffer(initialSize); |
|
var size = 0; |
|
|
|
this.writable = true; |
|
this.readable = false; |
|
|
|
this.size = function() { |
|
return size; |
|
}; |
|
|
|
this.maxSize = function() { |
|
return buffer.length; |
|
}; |
|
|
|
this.getContents = function(length) { |
|
if(!size) return false; |
|
|
|
var data = new Buffer(Math.min(length || size, size)); |
|
buffer.copy(data, 0, 0, data.length); |
|
|
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(data.length < size) |
|
<span class="cstat-no" title="statement not covered" > buffer.copy(buffer, 0, data.length);</span> |
|
|
|
size -= data.length; |
|
|
|
return data; |
|
}; |
|
|
|
this.getContentsAsString = function(encoding, length) { |
|
if(!size) return false; |
|
|
|
var data = buffer.toString(encoding || "utf8", 0, Math.min(length || size, size)); |
|
var dataLength = Buffer.byteLength(data); |
|
|
|
if(dataLength < size) |
|
buffer.copy(buffer, 0, dataLength); |
|
|
|
size -= dataLength; |
|
return data; |
|
}; |
|
|
|
var increaseBufferIfNecessary = function(incomingDataSize) { |
|
if((buffer.length - size) < incomingDataSize) { |
|
var factor = Math.ceil((incomingDataSize - (buffer.length - size)) / incrementAmount); |
|
|
|
var newBuffer = new Buffer(buffer.length + (incrementAmount * factor)); |
|
buffer.copy(newBuffer, 0, 0, size); |
|
buffer = newBuffer; |
|
} |
|
}; |
|
|
|
this.write = function(data, encoding, callback) { |
|
if(!that.writable) return; |
|
|
|
if(Buffer.isBuffer(data)) { |
|
increaseBufferIfNecessary(data.length); |
|
data.copy(buffer, size, 0); |
|
size += data.length; |
|
} |
|
else { |
|
data = data + ""; |
|
increaseBufferIfNecessary(Buffer.byteLength(data)); |
|
buffer.write(data, size, encoding || "utf8"); |
|
size += Buffer.byteLength(data); |
|
} |
|
|
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(typeof callback === "function") { <span class="cstat-no" title="statement not covered" >callback() ;}</span> |
|
}; |
|
|
|
this.end = function() { |
|
var args = Array.prototype.slice.apply(arguments); |
|
<span class="missing-if-branch" title="else path not taken" >E</span>if(args.length) that.write.apply(that, args); |
|
that.emit('finish'); |
|
that.destroy(); |
|
}; |
|
|
|
this.destroySoon = this.destroy = function() { |
|
that.writable = false; |
|
that.emit("close"); |
|
}; |
|
}; |
|
util.inherits(WritableStreamBuffer, stream.Stream); |
|
</pre></td></tr> |
|
</table></pre> |
|
|
|
</div> |
|
<div class="footer"> |
|
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Wed Jul 01 2015 04:16:19 GMT+0000 (UTC)</div> |
|
</div> |
|
<script src="../prettify.js"></script> |
|
<script> |
|
window.onload = function () { |
|
if (typeof prettyPrint === 'function') { |
|
prettyPrint(); |
|
} |
|
}; |
|
</script> |
|
<script src="../sorter.js"></script> |
|
</body> |
|
</html>
|
|
|