Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getLinkedObjectProperties(
lrs: LinkReduxLRSType,
context: LinkRenderContext,
subjProps: Statement[],
): PropertyBoundProps {
const acc: PropertyBoundProps = {};
for (const propOpts of Object.values(propMap)) {
for (const cur of propOpts.label) {
if (acc[propOpts.name]) {
// TODO: Merge
continue;
}
if (propOpts.limit === 1) {
const p = getPropBestLangRaw(
lrs.getResourcePropertyRaw(context.subject, cur),
(lrs as any).store.langPrefs,
);
if (p) {
acc[propOpts.name] = toReturnType(returnType, p);
}
} else {
acc[propOpts.name] = subjProps
.filter((s: Statement) => s.predicate.sI === cur.sI)
.map(
(s: Statement) => toReturnType(returnType, s),
) as Statement[] | SomeTerm[] | string[];
}
}
}
returnType: LinkReturnType,
): PropertyBoundProps {
const lrs = useLRS();
const context = useLinkRenderContext();
const acc: PropertyBoundProps = {};
for (const propOpts of Object.values(propMap)) {
for (const cur of propOpts.label) {
if (acc[propOpts.name]) {
// TODO: Merge
continue;
}
if (propOpts.limit === 1) {
const p = getPropBestLangRaw(
lrs.getResourcePropertyRaw(context.subject, cur),
(lrs as any).store.langPrefs,
);
if (p) {
acc[propOpts.name] = toReturnType(returnType, p);
}
} else {
acc[propOpts.name] = subjProps
.filter((s: Quad) => rdfFactory.id(s.predicate) === rdfFactory.id(cur))
.map((s: Quad) => toReturnType(returnType, s)) as Quad[] | SomeTerm[] | string[];
}
}
}
return acc;
}