/usr/lib/nodejs/node-xmpp/stream_shaper.js is in node-node-xmpp 0.3.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /**
* This is extremely simple and unprecise.
*
* @param {Number} rateLimit B/ms or KB/s
*/
exports.attach = function(stream, rateLimit) {
var timer;
stream.rateLimit = rateLimit; // makes it readjustable after attachment
stream.addListener('data', function(data) {
if (timer)
clearTimeout(timer);
stream.pause();
var sleep = Math.floor(data.length / stream.rateLimit);
timer = setTimeout(function() {
timer = undefined;
stream.resume();
}, sleep);
});
stream.addListener('close', function() {
// don't let the last timeout inhibit node shutdown
if (timer)
clearTimeout(timer);
});
};
|