schema-client
Advanced tools
Comparing version 3.0.9 to 3.0.10
@@ -339,3 +339,3 @@ var events = require('events'); | ||
var result; | ||
if (response.$data && typeof response.$data === 'object') { | ||
if (typeof response.$data === 'object') { | ||
result = Client.createResource(url, response, self); | ||
@@ -342,0 +342,0 @@ } else { |
@@ -61,3 +61,3 @@ var inherits = require('util').inherits; | ||
}); | ||
this.stream.on('error', this.close.bind(this)); | ||
this.stream.on('error', this.error.bind(this)); | ||
this.stream.on('data', this.receive.bind(this)); | ||
@@ -169,5 +169,14 @@ this.stream.on('close', this.close.bind(this)); | ||
/** | ||
* Emit an error | ||
* | ||
* @param Error error | ||
*/ | ||
Connection.prototype.error = function(error) { | ||
this.emit('error', error); | ||
}; | ||
/** | ||
* Close this connection | ||
*/ | ||
Connection.prototype.close = function(error) { | ||
Connection.prototype.close = function() { | ||
if (!this.connected) { | ||
@@ -185,15 +194,5 @@ return; | ||
var hasRequests = this.requestBuffer.length; | ||
if (error || hasRequests) { | ||
this.emit('error.network', error || DEFAULT_NETWORK_ERROR); | ||
if (this.requestBuffer.length > 0) { | ||
this.connect(); | ||
} | ||
var responder; | ||
while (--hasRequests >= 0) { | ||
responder = this.requestBuffer.shift().pop(); | ||
responder({ | ||
$status: 500, | ||
$error: error || DEFAULT_NETWORK_ERROR | ||
}); | ||
} | ||
}; | ||
@@ -200,0 +199,0 @@ |
{ | ||
"name": "schema-client", | ||
"version": "3.0.9", | ||
"version": "3.0.10", | ||
"description": "Schema API Client for NodeJS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
117703
3641