Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
pipe with promises
exports.pipe = function (source, sink) {
var deferred = Q.defer();
.on("end", deferred.resolve)
.on("error", deferred.reject)
.on("error", deferred.reject);
deferred.promise.finally(function () {
source.removeListener("end", deferred.resolve);
source.removeListener("error", deferred.reject);
sink.removeListener("error", deferred.reject);
return deferred.promise;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment