Comparing version 1.1.0 to 1.1.1
@@ -64,3 +64,10 @@ 'use strict'; | ||
return Promise.resolve(n.response); | ||
if (n.status === 1 || n.response != null) { | ||
return Promise.resolve(n.response); | ||
} | ||
let err = new Error('Notification was cancelled.'); | ||
err.code = 'ECANCELED'; | ||
return Promise.reject(err); | ||
} | ||
@@ -76,3 +83,6 @@ }; | ||
return Promise.reject(new Error(n.name + ' was published but has no subscribers.')); | ||
let err = new Error(n.name + ' was published but has no subscribers.'); | ||
err.code = 'ENOSYS'; | ||
return Promise.reject(err); | ||
} | ||
@@ -92,3 +102,2 @@ | ||
pending.splice(pending.indexOf(notification), 1); | ||
notification = null; | ||
} | ||
@@ -136,2 +145,3 @@ | ||
interests = {}; | ||
pending.forEach(cancelNotification); | ||
pending = []; | ||
@@ -138,0 +148,0 @@ } |
{ | ||
"name": "handoff", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "PubSub with Promises", | ||
@@ -5,0 +5,0 @@ "main": "handoff.js", |
@@ -126,19 +126,18 @@ var handoff = require('../handoff'); | ||
it('should be able to cancel notifications', done => { | ||
it('should be able to cancel notifications', function () { | ||
handoff.subscribe('cancel-test-2', function (n) { | ||
n.cancel(); | ||
setTimeout(() => { | ||
done(); | ||
}, 10); | ||
return 'cancelled'; | ||
}); | ||
handoff.subscribe('cancel-test-2', function (n) { | ||
done(false); | ||
return 'not cancelled'; | ||
}); | ||
handoff.publish('cancel-test-2'); | ||
return handoff.publish('cancel-test-2').then(response => { | ||
expect(response).to.equal('cancelled'); | ||
}); | ||
}); | ||
}); | ||
}); |
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
12095
238