add getSplittedAttributes helper

This commit is contained in:
Philipp Kühn
2021-01-29 09:33:42 +01:00
parent 72ff2d212e
commit 97eb9c411c
3 changed files with 46 additions and 45 deletions

View File

@@ -0,0 +1,21 @@
import { AnyObject, ExtensionAttribute } from '../types'
export default function getSplittedAttributes(
extensionAttributes: ExtensionAttribute[],
typeName: string,
attributes: AnyObject,
): AnyObject {
return Object.fromEntries(Object
.entries(attributes)
.filter(([name]) => {
const extensionAttribute = extensionAttributes.find(item => {
return item.type === typeName && item.name === name
})
if (!extensionAttribute) {
return false
}
return extensionAttribute.attribute.keepOnSplit
}))
}