simple-websocket
Advanced tools
Comparing version 7.0.0 to 7.0.1
31
index.js
@@ -70,3 +70,6 @@ /* global WebSocket, DOMException */ | ||
} catch (err) { | ||
return self.destroy(err) | ||
process.nextTick(function () { | ||
self._destroy(err) | ||
}) | ||
return | ||
} | ||
@@ -106,17 +109,6 @@ } | ||
// TODO: Delete this method once readable-stream is updated to contain a default | ||
// implementation of destroy() that automatically calls destroy() | ||
// implementation of destroy() that automatically calls _destroy() | ||
// See: https://github.com/nodejs/readable-stream/issues/283 | ||
Socket.prototype.destroy = function (err) { | ||
var self = this | ||
self._destroy(err, function (err) { | ||
if (err) { | ||
if (typeof DOMException !== 'undefined' && err instanceof DOMException) { | ||
// Convert Edge DOMException object to Error object | ||
var code = err.code | ||
err = new Error(err.message) | ||
err.code = code | ||
} | ||
process.nextTick(function () { self.emit('error', err) }) | ||
} | ||
}) | ||
this._destroy(err, function () {}) | ||
} | ||
@@ -167,4 +159,13 @@ | ||
cb(err) | ||
if (err) { | ||
if (typeof DOMException !== 'undefined' && err instanceof DOMException) { | ||
// Convert Edge DOMException object to Error object | ||
var code = err.code | ||
err = new Error(err.message) | ||
err.code = code | ||
} | ||
self.emit('error', err) | ||
} | ||
self.emit('close') | ||
cb() | ||
} | ||
@@ -171,0 +172,0 @@ |
{ | ||
"name": "simple-websocket", | ||
"description": "Simple, EventEmitter API for WebSockets (browser)", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh", |
Sorry, the diff of this file is too big to display
877
97386