const Rx = require('rxjs');
const proto = Rx.Observable.prototype;
proto.whenCompleted = function () {
const source = this;
return Rx.Observable.create(sub => {
const ret = [];
return source.subscribe(
function (v) {
ret.push(v);
},
function (e) {
sub.error(e);
},
function () {
sub.error(ret);
}
)
});
};
module.exports = Rx;