Move marker and error handling so that it doesn't occur for every single successful value

master
Sven Slootweg 4 years ago
parent f7cccea149
commit 2976a37e0e

@ -3,8 +3,8 @@
const Promise = require("bluebird"); const Promise = require("bluebird");
const propagateAbort = require("@ppstreams/propagate-abort"); const propagateAbort = require("@ppstreams/propagate-abort");
const propagatePeek = require("@ppstreams/propagate-peek"); const propagatePeek = require("@ppstreams/propagate-peek");
const { isEndOfStream } = require("@ppstreams/end-of-stream-marker"); const isEndOfStream = require("@ppstreams/is-end-of-stream");
const { isAborted } = require("@ppstreams/aborted-marker"); const isAborted = require("@ppstreams/is-aborted");
const { validateOptions } = require("@validatem/core"); const { validateOptions } = require("@validatem/core");
const required = require("@validatem/required"); const required = require("@validatem/required");
@ -47,6 +47,11 @@ module.exports = function simpleSinkStream(_options) {
}).then((result) => { }).then((result) => {
lastResult = result; lastResult = result;
return attemptRead();
});
}
return Promise.try(() => {
return attemptRead(); return attemptRead();
}).catch(isEndOfStream, () => { }).catch(isEndOfStream, () => {
/* Don't attempt to do another read, we're done. */ /* Don't attempt to do another read, we're done. */
@ -98,8 +103,5 @@ module.exports = function simpleSinkStream(_options) {
} }
}); });
} }
return attemptRead();
}
}; };
}; };

Loading…
Cancel
Save