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.Pattern, context: ActionContext)
: Promise {
// Resolve the quad pattern
const result = await this.mediatorResolveQuadPattern.mediate({ pattern, context });
// Collect all variables from the pattern
const variables: string[] = this.getVariables(pattern);
// Convenience datastructure for mapping quad elements to variables
const elementVariables: {[key: string]: string} = reduceTerms(pattern,
(acc: {[key: string]: string}, term: RDF.Term, key: QuadTermName) => {
if (ActorQueryOperationQuadpattern.isTermVariable(term)) {
acc[key] = termToString(term);
}
return acc;
}, {});
const quadBindingsReducer = (acc: {[key: string]: RDF.Term}, term: RDF.Term, key: QuadTermName) => {
const variable: string = elementVariables[key];
if (variable) {
acc[variable] = term;
}
return acc;
};
const bindingsStream: BindingsStream = new PromiseProxyIterator(async () => result.data.map((quad) => {
return Bindings(reduceTerms(quad, quadBindingsReducer, {}));
const bindingsStream: BindingsStream = new PromiseProxyIterator(async () => result.data.map((quad) => {
return Bindings(reduceTerms(quad, quadBindingsReducer, {}));
}, { autoStart: true, maxBufferSize: 128 }));