Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*! @license MIT ©2014-2016 Ruben Verborgh, Ghent University - imec */
/* A ReorderingGraphPatternIterator builds bindings by reading matches for a basic graph pattern. */
var AsyncIterator = require('asynciterator'),
TransformIterator = AsyncIterator.TransformIterator,
MultiTransformIterator = AsyncIterator.MultiTransformIterator,
rdf = require('../util/RdfUtil'),
_ = require('lodash'),
Logger = require('../util/ExecutionLogger')('ReorderingGraphPatternIterator');
var TriplePatternIterator = require('./TriplePatternIterator');
// Creates a new ReorderingGraphPatternIterator
function ReorderingGraphPatternIterator(parent, pattern, options) {
// Empty patterns have no effect
if (!pattern || !pattern.length)
return new TransformIterator(parent, options);
// A one-element pattern can be solved by a triple pattern iterator
if (pattern.length === 1)
return new TriplePatternIterator(parent, pattern[0], options);
// For length two or more, construct a ReorderingGraphPatternIterator
if (!(this instanceof ReorderingGraphPatternIterator))
/*! @license MIT ©2014-2016 Ruben Verborgh, Ghent University - imec */
/* A TriplePatternIterator builds bindings by reading matches for a triple pattern. */
var AsyncIterator = require('asynciterator'),
MultiTransformIterator = AsyncIterator.MultiTransformIterator,
rdf = require('../util/RdfUtil'),
Logger = require('../util/ExecutionLogger')('TriplePatternIterator');
// Creates a new TriplePatternIterator
function TriplePatternIterator(parent, pattern, options) {
if (!(this instanceof TriplePatternIterator))
return new TriplePatternIterator(parent, pattern, options);
MultiTransformIterator.call(this, parent, options);
this._pattern = pattern;
this._client = options && options.fragmentsClient;
}
MultiTransformIterator.subclass(TriplePatternIterator);
// Creates a transformer that extends upstream bindings with matches for the triple pattern.
// For example, if the iterator's triple pattern is '?s rdf:type ?o',