Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async runOperation(pattern: Algebra.Filter, context: ActionContext)
: Promise {
const output: IActorQueryOperationOutputBindings = ActorQueryOperation.getSafeBindings(
await this.mediatorQueryOperation.mediate({ operation: pattern.input, context }));
ActorQueryOperation.validateQueryOutput(output, 'bindings');
const exprFunc = SparqlExpressionEvaluator.createEvaluator(pattern.expression);
const filter = (bindings: Bindings) => {
try {
const term = exprFunc(bindings);
return term && term.value !== 'false' && term.value !== '0';
} catch (e) {
bindingsStream.emit('error', e);
return false;
}
};
const bindingsStream = output.bindingsStream.filter(filter);
return { type: 'bindings', bindingsStream, metadata: output.metadata, variables: output.variables };
}
public async runOperation(pattern: Algebra.Filter, context: ActionContext)
: Promise {
const outputRaw = await this.mediatorQueryOperation.mediate({ operation: pattern.input, context });
const output = ActorQueryOperation.getSafeBindings(outputRaw);
ActorQueryOperation.validateQueryOutput(output, 'bindings');
const { variables, metadata } = output;
const expressionContext = ActorQueryOperation.getExpressionContext(context);
const config = {
...expressionContext,
exists: this.createExistenceResolver(context),
};
const evaluator = new AsyncEvaluator(pattern.expression, config);
const transform = async (item: Bindings, next: any) => {
try {
const result = await evaluator.evaluateAsEBV(item);
if (result) {
bindingsStream._push(item);
}
} catch (err) {