Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function UnionIterator(sources, options) {
if (!(this instanceof UnionIterator))
return new UnionIterator(sources, options);
BufferedIterator.call(this, options);
// Construct a list of readable sources
this._sources = [];
this._sourceIndex = 0;
if (sources && sources.length) {
// Create event listeners
var self = this;
function fillBuffer() { self._fillBuffer(); }
function emitError(error) { self.emit('error', error); }
// Add all readable sources and listen to their events
for (var i = 0, l = sources.length; i < l; i++) {
var source = sources[i];
if (source && !source.ended) {
this._sources.push(source);
source.on('readable', fillBuffer);
function CompoundFragment(fragments, options) {
if (!(this instanceof CompoundFragment))
return new CompoundFragment(fragments, options);
BufferedIterator.call(this, options);
// If no fragments are given, the fragment is empty
if (!fragments || !fragments.length)
return this.empty(), this;
// Index fragments for processing and initialize metadata
var fragmentsPending = fragments.length,
metadataPending = fragments.length,
errorThreshold = options.errorThreshold || 0,
combinedMetadata = this._metadata = { totalTriples: 0 };
fragments = this._fragments = _.indexBy(fragments, getIndex);
// Combine all fragments into a single fragment
var compoundFragment = this;
_.each(fragments, function (fragment, index) {
fragment.on('readable', setReadable);
function Fragment(fragmentsClient, pattern) {
if (!(this instanceof Fragment))
return new Fragment(fragmentsClient);
BufferedIterator.call(this);
this._fragmentsClient = fragmentsClient;
this._pattern = pattern;
}
BufferedIterator.subclass(Fragment);