Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const proxyIt: AsyncIterator> = sourcesIt.map((source) => {
remainingSources++;
sourcesCount++;
// If we can predict that the given source will have no bindings for the given pattern,
// return an empty iterator.
const pattern: Algebra.Pattern = this.algebraFactory.createPattern(
FederatedQuadSource.nullToVariable(subject, 's'),
FederatedQuadSource.nullToVariable(predicate, 'p'),
FederatedQuadSource.nullToVariable(object, 'o'),
FederatedQuadSource.nullToVariable(graph, 'g'),
);
// Prepare the context for this specific source
const context: ActionContext = this.contextDefault.set(KEY_CONTEXT_SOURCE,
{ type: getDataSourceType(source), value: getDataSourceValue(source) });
return new PromiseProxyIterator(async () => {
let output: IActorRdfResolveQuadPatternOutput;
if (this.isSourceEmpty(source, pattern)) {
output = { data: new EmptyIterator(), metadata: () => Promise.resolve({ totalItems: 0 }) };
} else {
output = await this.mediatorResolveQuadPattern.mediate({ pattern, context });
}
if (output.metadata) {
output.metadata().then((subMetadata: {[id: string]: any}) => {
if ((!subMetadata.totalItems && subMetadata.totalItems !== 0) || !isFinite(subMetadata.totalItems)) {
metadata.totalItems = Infinity;
remainingSources = 0; // We're already at infinite, so ignore any later metadata
checkEmitMetadata(Infinity, source, pattern, subMetadata);
} else {
metadata.totalItems += subMetadata.totalItems;