This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const async = require('async'); | |
const pg = require('pg') | |
// QueryConnect: (QuerySource, Callback) -> Connection | |
// QueryDisconnect: Connection -> Connection | |
// getSmartQuery : (QueryConnect, QueryDisconnect, QuerySource) -> SmartQuery | |
function getSmartQuery(connect, disconnect, querySource) { | |
let conn = null; | |
function connectClient(query, _connectClient) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Listens to an EventEmitter and reduces the data returned. The EventEmitter must at least three types of events: | |
- dataEvent: it sends the data to be reduced | |
- endEvent: it signals the completion of the operation | |
- errorEvent: it sends an error. The operation is interrupted to handle it | |
*/ | |
function reduceEventEmmitter({dataEvent, endEvent, errorEvent = null}, accumulator = [], reducer, eventEmitter, cb) { | |
eventEmitter.on(dataEvent, function handleDataEvent(data) { | |
accumulator = reducer(accumulator, data); | |
}); |
OlderNewer