Comparing version 0.2.0 to 0.2.1
@@ -159,3 +159,3 @@ 'use strict' | ||
if (this._pendings.has(UID)) { | ||
fulfill(this, UID, new RangeError('UID overflow error. This transaction was never resolved, and its UID is needed by a newer transaction.')) | ||
fulfill(this, UID, new RangeError('UID overflow error. This transaction was never resolved, and its UID is needed by a newer transaction.'), true) | ||
} | ||
@@ -296,11 +296,16 @@ this._ws.send(message) | ||
function registerTransaction(eva, UID) { | ||
return new Promise(function (resolve, reject) { | ||
eva._pendings.set(UID, {resolve: resolve, reject: reject}) | ||
var fate | ||
var promise = new Promise(function (resolve, reject) { | ||
fate = {resolve: resolve, reject: reject, promise: null} | ||
}).bind(eva) | ||
fate.promise = promise | ||
eva._pendings.set(UID, fate) | ||
return promise | ||
} | ||
function fulfill(eva, response, UID) { | ||
function fulfill(eva, response, UID, supress) { | ||
var fate = eva._pendings.get(UID) | ||
if (fate) { | ||
eva._pendings.delete(UID) | ||
supress && fate.promise.suppressUnhandledRejections() | ||
;(response instanceof Error ? fate.reject : fate.resolve)(response) | ||
@@ -358,3 +363,3 @@ } | ||
eva._pendings.forEach(function (fate, UID) { | ||
fulfill(eva, new Error('Connection was lost.'), UID) | ||
fulfill(eva, new Error('Connection was lost.'), UID, true) | ||
}) | ||
@@ -361,0 +366,0 @@ eva._internal.removeAllListeners() |
{ | ||
"name": "eva-events", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Eva is like an EventEmitter, but over WebSockets.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -34,3 +34,4 @@ ![Image of Eve](http://s11.postimg.org/h1cc0m88z/eveflying.jpg) | ||
.then(function (reply) { | ||
console.log(reply instanceof Date) // true | ||
reply instanceof Date // true | ||
this === eva // true | ||
}) | ||
@@ -37,0 +38,0 @@ }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32502
628
202