Skip to content

Instantly share code, notes, and snippets.

@aredridel
Created September 3, 2015 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/80eaa89623ff78ff9a6d to your computer and use it in GitHub Desktop.
Save aredridel/80eaa89623ff78ff9a6d to your computer and use it in GitHub Desktop.
Evil hack
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