Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const transform = async (bindings: Bindings, next: any) => {
try {
const result = await evaluator.evaluate(bindings);
// Extend operation is undefined when the key already exists
// We just override it here.
const extended = bindings.set(extendKey, result);
bindingsStream._push(extended);
} catch (err) {
if (isExpressionError(err)) {
// Errors silently don't actually extend according to the spec
bindingsStream._push(bindings);
// But let's warn anyway
this.logWarn(context, `Expression error for extend operation with bindings '${JSON.stringify(bindings)}'`);
} else {
bindingsStream.emit('error', err);
}
}
next();
};
const transform = async (item: Bindings, next: any) => {
try {
const result = await evaluator.evaluateAsEBV(item);
if (result) {
bindingsStream._push(item);
}
} catch (err) {
if (!isExpressionError(err)) {
bindingsStream.emit('error', err);
}
}
next();
};
transform: async (innerItem: Bindings, nextInner: any) => {
const joinedBindings = ActorRdfJoin.join(outerItem, innerItem);
if (!joinedBindings) { nextInner(); return; }
if (!pattern.expression) {
joinedStream._push({ joinedBindings, result: true });
nextInner();
return;
}
try {
const result = await evaluator.evaluateAsEBV(joinedBindings);
joinedStream._push({ joinedBindings, result });
} catch (err) {
if (!isExpressionError(err)) {
bindingsStream.emit('error', err);
}
}
nextInner();
},
});
const transform = async (bindings: Bindings, next: any) => {
try {
const result = await evaluator.evaluate(bindings);
transformedStream._push({ bindings, result });
} catch (err) {
if (!isExpressionError(err)) {
bindingsStream.emit('error', err);
}
transformedStream._push({ bindings, result: undefined });
}
next();
};
const transformedStream = bindingsStream.transform({ transform });