/usr/lib/nodejs/read-only-stream/index.js is in node-read-only-stream 2.0.0-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 26 27 28 29 30 | var Readable = require('readable-stream').Readable;
module.exports = function (stream) {
var opts = stream._readableState;
if (typeof stream.read !== 'function') {
stream = new Readable(opts).wrap(stream);
}
var ro = new Readable({ objectMode: opts && opts.objectMode });
var waiting = false;
stream.on('readable', function () {
if (waiting) {
waiting = false;
ro._read();
}
});
ro._read = function () {
var buf, reads = 0;
while ((buf = stream.read()) !== null) {
ro.push(buf);
reads ++;
}
if (reads === 0) waiting = true;
};
stream.once('end', function () { ro.push(null) });
stream.on('error', function (err) { ro.emit('error', err) });
return ro;
};
|