Created
May 4, 2016 15:42
-
-
Save jcready/f9b288a0044985c31b436b7c394fa1c4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function(){ | |
const EE = require('events') | |
const Stream = require('stream') | |
const promise = Symbol('StreamPromise') | |
Stream.prototype.constructor = function () { | |
EE.call(this) | |
this[promise] = new Promise((resolve, reject) => { | |
this.on('error', reject) | |
this.on('end', resolve) | |
this.on('finish', resolve) | |
}) | |
} | |
Stream.prototype.then = function (yay, nay) { | |
return this[promise].then(yay, nay) | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment