Created
September 3, 2015 17:30
-
-
Save aredridel/80eaa89623ff78ff9a6d to your computer and use it in GitHub Desktop.
Evil hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var P = require('bluebird'); | |
var tap = require('tap'); | |
var pt = wrap(tap); | |
function wrap(orig) { | |
return Object.create(orig, { | |
test: { | |
value: function(name, options, cb) { | |
if (!cb) { | |
cb = options; | |
options = {}; | |
} | |
var self = this; | |
return new P(function(y, n) { | |
orig.test.call(self, name, options, function(t) { | |
t.on('end', function() { | |
if (t._ok) { | |
y(); | |
} else { | |
n(); | |
} | |
}); | |
cb(wrap(t)); | |
}); | |
}); | |
} | |
} | |
}); | |
} | |
module.exports = pt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment