Code coverage report for etoa.js

# All files etoa.js

100% Statements 17/17
87.5% Branches 7/8
100% Functions 4/4
100% Lines 16/16

    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
    291x

    1x

    2x
    7x
    2x

    2x
    2x
    9x
    7x
    7x
    7x
    19x
    19x

    7x

    9x

    2x

     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)
            for (var i = 0; i < l; i++) {
              var arg = arguments[i]
              args[i] = (arg instanceof EE) ?
                eventsToArray(arg, ignore) :
                arg
            }
            array.push(map(args))
          }

          return orig.apply(this, arguments)
        }
      })(ee.emit)

      return array
    }