Expect explicit source stream marker

master
Sven Slootweg 3 years ago
parent 2d17b4019e
commit b3537911d4

@ -38,7 +38,8 @@ module.exports = function pipe(_streams) {
throw new Error("Must specify at least one stream when defining a pipeline");
} else {
let firstStream = streams[0];
let requiresSource = (firstStream.read.length > 0 && firstStream._promistreamHasSource !== true);
// NOTE: firstStream._promistreamHasSource is backwards compatibility; to be removed in promistreamVersion:1
let requiresSource = (firstStream._promistreamHasSource !== true && firstStream._promistreamIsSource !== true);
/* NOTE: We never clean up the cache, because it's very unlikely that this cache will ever grow big. In the vast majority of cases, it's going to contain at most one item. So instead, we let the garbage collector worry about getting rid of it once the pipeline itself becomes obsolete. */
let boundPipelineCache = new Map();
@ -78,8 +79,8 @@ module.exports = function pipe(_streams) {
}
return {
// NOTE: This is set to convey to other `pipe` calls (as well as any other composability tools) that this is explicitly a composed stream that does not require a source, even if the `read` signature suggests otherwise. FIXME: Figure out how and whether to spec this, or whether there is a better way to deal with this.
_promistreamHasSource: !requiresSource,
_promistreamHasSource: !requiresSource, // For backwards compatibility, to be removed in promistreamVersion:1
_promistreamIsSource: !requiresSource,
_promistreamVersion: 0,
description: `piped stream [${streams.map((stream) => stream.description).join(" => ")}]`,
read: function (source) {

Loading…
Cancel
Save