How to use the asynciterator.TransformIterator function in asynciterator

To help you get started, we’ve selected a few asynciterator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LinkedDataFragments / Client.js / lib / util / HttpClient.js View on Github external
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;
};
github Callidon / sparql-engine / src / rdf / graph.js View on Github external
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
  }
}
github LinkedDataFragments / Client.js / test / lib / FileFragmentsClient.js View on Github external
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;
};