Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
HttpClient.prototype.request = function (url, method, headers, options) {
var request = _.assign({
id: this._requestId++,
startTime: new Date(),
url: url,
method: method || 'GET',
headers: _.assign({}, this._defaultHeaders, headers),
timeout: 5000,
followRedirect: true,
// maximize buffer size to drain the response stream, since unconsumed responses
// can lead to out-of-memory errors (http://nodejs.org/api/http.html)
response: new TransformIterator({ maxBufferSize: Infinity }),
}, options);
// Queue the request and start it when possible
this._queued.push(request);
this._startNextRequest();
return request.response;
};
evalBGP (bgp, options) {
const iter = new TransformIterator()
// collect cardinalities of each triple pattern
Promise.all(bgp.map(triple => {
return this.estimateCardinality(triple).then(c => {
return {triple, cardinality: c, nbVars: countVariables(triple)}
})
})).then(results => {
results.sort(sortPatterns)
iter.source = results.reduce((iter, v) => {
return new IndexJoinOperator(iter, v.triple, this, options)
}, single({}))
})
return iter
}
}
FileFragmentsClient.prototype.getFragmentByPattern = function (pattern) {
var filename = this._getPath(pattern) + '.ttl',
triples = new TransformIterator(),
metadata = this._metadata[this._getIdentifier(pattern)];
fs.exists(filename, function (exists) {
if (!exists) return triples.close();
triples.source = fs.createReadStream(filename).pipe(N3.StreamParser());
});
triples.on('error', console.error);
triples.setProperty('metadata', metadata);
return triples;
};