Allow Serial nodes to close asynchonously

This commit is contained in:
Nick O'Leary
2014-05-14 21:34:17 +01:00
parent c317ccc36d
commit 8f1dd62515
2 changed files with 19 additions and 11 deletions

View File

@@ -35,11 +35,12 @@ function Node(n) {
}
Node.prototype.on = function(event,callback) {
var node = this;
if (event == "close") {
if (callback.length == 1) {
this.close = function() {
return when.promise(function(resolve) {
callback(function() {
callback.call(node,function() {
resolve();
});
});