/usr/lib/nodejs/events-to-array/etoa.js is in node-tap-parser 7.0.0+ds1-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 31 32 33 34 | module.exports = eventsToArray
var EE = require('events').EventEmitter
function eventsToArray (ee, ignore, map) {
ignore = ignore || []
map = map || function (x) { return x }
var array = []
ee.emit = (function (orig) {
return function etoaWrap (ev) {
if (ignore.indexOf(ev) === -1) {
var l = arguments.length
var args = new Array(l)
// intentionally sparse array
var swap = []
for (var i = 0; i < l; i++) {
var arg = arguments[i]
args[i] = arguments[i]
if (arg instanceof EE)
swap[i] = eventsToArray(arg, ignore, map)
}
args = args.map(map)
args = args.map(function (arg, index) {
return swap[index] || arg
})
array.push(args)
}
return orig.apply(this, arguments)
}
})(ee.emit)
return array
}
|