Code coverage report for beefy/lib/accumulate-error.js

Statements: 100% (13 / 13)      Branches: 100% (2 / 2)      Functions: 100% (3 / 3)      Lines: 100% (13 / 13)      Ignored: none     

All files » beefy/lib/ » accumulate-error.js
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 351   1         1         1 5     5   1 1     1 2 1 1         2        
module.exports = accumError
 
var Buffer = require('buffer').Buffer
  , through = require('through')
  , path = require('path')
  , fs = require('fs')
 
var DOMError = fs.readFileSync(
    path.join(__dirname, 'frontend-js', 'error.js')
  , 'utf8'
)
 
function accumError(outputError, resp) {
  var stream = through(write, end)
    , error = []
 
  return stream
 
  function write(buf) {
    error.push(buf)
  }
 
  function end() {
    if(error.length) {
      outputError(Buffer.concat(error))
      resp.end(
          '(' + DOMError + ')(' + JSON.stringify(error + '') + ')'
      )
    }
 
    stream.queue(null)
  }
}