diff --git a/lib/native/index.js b/lib/native/index.js index 599ad25b..3a1c2f90 100644 --- a/lib/native/index.js +++ b/lib/native/index.js @@ -8,12 +8,12 @@ var CopyToStream = require(__dirname + '/../copystream').CopyToStream; var binding; -try{ +try { //v0.5.x - binding = require(__dirname + '/../../build/Release/binding.node'); + binding = require(__dirname + '/../../build/Release/binding.node'); } catch(e) { //v0.4.x - binding = require(__dirname + '/../../build/default/binding'); + binding = require(__dirname + '/../../build/default/binding'); } var Connection = binding.Connection; @@ -59,7 +59,7 @@ p._copy = function (text, stream) { } else { q.stream.close(); } - }); + }); q.stream = stream; this._queryQueue.push(q); this._pulseQueryQueue(); @@ -72,13 +72,14 @@ p.copyTo = function (text) { return this._copy(text, new CopyToStream()); }; p.sendCopyFromChunk = function (chunk) { - this._sendCopyFromChunk(chunk); + this._sendCopyFromChunk(chunk); }; p.endCopyFrom = function (msg) { this._endCopyFrom(msg); }; p.query = function(config, values, callback) { - var query = (config instanceof NativeQuery) ? config : new NativeQuery(config, values, callback); + var query = (config instanceof NativeQuery) ? config : + new NativeQuery(config, values, callback); this._queryQueue.push(query); this._pulseQueryQueue(); return query; @@ -203,14 +204,16 @@ var clientBuilder = function(config) { }); connection.on('copyInResponse', function () { //connection is ready to accept chunks - //start to send data from stream + //start to send data from stream connection._activeQuery.streamData(connection); }); connection.on('copyOutResponse', function(msg) { - if (connection._activeQuery.stream === undefined) { - connection._activeQuery._canceledDueToError = new Error('No destination stream defined'); - (new clientBuilder({port: connection.port, host: connection.host})).cancel(connection, connection._activeQuery); - } + if (connection._activeQuery.stream === undefined) { + connection._activeQuery._canceledDueToError = + new Error('No destination stream defined'); + (new clientBuilder({port: connection.port, host: connection.host})) + .cancel(connection, connection._activeQuery); + } }); connection.on('copyData', function (chunk) { //recieve chunk from connection