'use strict'; var _ = require('underscore'); var Pg = require('./../pg'); const errorHandlerFactory = require('../../../services/error_handler_factory'); function JsonFormat() { this.buffer = ''; this.lastKnownResult = {}; } JsonFormat.prototype = new Pg('json'); JsonFormat.prototype._contentType = "application/json; charset=utf-8"; // jshint maxcomplexity:10 JsonFormat.prototype.formatResultFields = function(flds) { flds = flds || []; var nfields = {}; for (var i=0; i 0 ) { var notices = {}, severities = []; _.each(result.notices, function(notice) { var severity = notice.severity.toLowerCase() + 's'; if (!notices[severity]) { severities.push(severity); notices[severity] = []; } notices[severity].push(notice.message); }); _.each(severities, function(severity) { out.push(','); out.push(JSON.stringify(severity)); out.push(':'); out.push(JSON.stringify(notices[severity])); }); } out.push('}'); this.buffer += out.join(''); if (this.opts.callback) { this.buffer += ')'; } this.opts.sink.write(this.buffer); this.opts.sink.end(); this.buffer = ''; this.callback(); }; module.exports = JsonFormat;