code: function collectJson (throughFunction) {
    var stream = collect(function (data) {
      try {
        var json = JSON.parse(data)
      } catch (err) {
        err.input = data
        err.message = 'collect-json: [' + err.message + '], input:\n' + data
        throw err
      }
      return json
    }, { readableObjectMode: true })
    if (throughFunction) {
      return connect(stream, through(throughFunction, { objectMode: true }))
    } else {
      return stream
    }
  }
docs: @param [callback] {function} - called with the collected json data, once available. The value returned by the callback will be passed downstream.
  @return {external:Duplex}
  @alias module:collect-json
  @example
  An example command-line client script - JSON received at stdin is stamped with `received` then written to stdout.
  ```js
  var collectJson = require("collect-json")
  
  process.stdin
  .pipe(collectJson(function(json){
  json.received = true
  return JSON.stringify(json)
  }))
  .on("error", function(err){
  // input from stdin failed to parse
  })
  .pipe(process.stdout)
  ```