How to use the asynciterator.wrap 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 beautifulinteractions / node-quadstore / lib / getstream / index.js View on Github external
const executeStrategy = (strategy, opts, store) => {
  const streamFactories = strategy.paths.map(
    (path) => generateStreamFactoryForPath(store, strategy, path),
  );
  let multiStream = multistream.obj(streamFactories);
  if (opts.offset || opts.limit) {
    let multiIterator = AsyncIterator.wrap(multiStream);
    if (opts.offset) {
      multiIterator = multiIterator.skip(opts.offset);
    }
    if (opts.limit) {
      multiIterator = multiIterator.take(opts.limit);
    }
    multiStream = utils.createIteratorStream(multiIterator);
  }
  return multiStream;
};
github beautifulinteractions / node-quadstore / lib / quadstore.js View on Github external
function _delStream(resolve, reject) {
      AsyncIterator.wrap(source).transform((quad, cb) => {
        store._delput([quad], [], opts, cb);
      })
        .on('data', utils.noop)
        .on('end', resolve)
        .on('error', reject);
    }
    if (!_.isFunction(cb)) {
github beautifulinteractions / node-quadstore / lib / getstream / index.js View on Github external
opts.lt = strategy.index.name + store.separator + path.lt.join(store.separator) + store.separator;
    } else if (path.lte && path.lte.length > 0) {
      opts.lte = strategy.index.name + store.separator + path.lte.join(store.separator) + store.separator + store.boundary;
    } else {
      opts.lt = strategy.index.name + store.separator + store.boundary;
    }
    if (path.gt && path.gt.length > 0) {
      opts.gt = strategy.index.name + store.separator + path.gt.join(store.separator) + store.boundary;
    } else if (path.gte && path.gte.length > 0) {
      opts.gte = strategy.index.name + store.separator + path.gte.join(store.separator) + store.separator;
    } else {
      opts.gt = strategy.index.name + store.separator;
    }
    let valueStream = store._db.createValueStream(opts);
    if (path.filter) {
      const valueIterator = AsyncIterator.wrap(valueStream)
        .filter(path.filter);
      valueStream = utils.createIteratorStream(valueIterator);
    }
    return valueStream;
  };
};
github beautifulinteractions / node-quadstore / lib / quadstore.js View on Github external
function _putStream(resolve, reject) {
      AsyncIterator.wrap(source).transform((quad, cb) => {
        store._delput([], [quad], opts, cb);
      })
        .on('data', utils.noop)
        .on('end', resolve)
        .on('error', reject);
    }
    if (!_.isFunction(cb)) {