Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
};
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)) {
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;
};
};
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)) {