UNPKG

rdf-dataset-fragmenter

Version:
36 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QuadSourceComposite = void 0; const node_stream_1 = require("node:stream"); /** * A quad source that combines multiple quad sources. * * Concretely, this will create a concatenated stream of all the given sources streams. */ class QuadSourceComposite { sources; constructor(sources) { this.sources = sources; } getQuads() { const concat = new node_stream_1.PassThrough({ objectMode: true }); let endedStreams = 0; for (const source of this.sources) { const stream = source.getQuads(); stream.pipe(concat, { end: false }); stream.on('error', error => concat.emit('error', error)); stream.on('end', () => { if (++endedStreams === this.sources.length) { concat.end(); } }); } // Special case when we have no sources if (this.sources.length === 0) { concat.end(); } return concat; } } exports.QuadSourceComposite = QuadSourceComposite; //# sourceMappingURL=QuadSourceComposite.js.map