Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const concatInputsAndState = (inputs, state = []) => {
const attributeKeys = map((item) => head(keys(item)), inputs)
return filter((item) => isNil(find(equals(item))(state)))(
concat(
inputs,
reduce(
(attributes, attribute) => {
const key = head(keys(attribute))
if (!contains(key, attributeKeys)) {
// return empty string to "unset" removed value
return concat(attributes, [{ [key]: '' }])
}
return attributes
},
[],
state
)
)
)
}
(attributes, key) => {
if (!contains(key, keys(inputs))) {
// return empty object to "unset" removed value
return concat(attributes, [{ [key]: {} }])
}
return attributes
},
[],
const evaluateVariableString = (variableString, data) => {
const { exact, match, expression } = matchVariable(variableString)
if (!match) {
return variableString
}
const resolvedExpression = evaluateVariableString(expression, data)
const self = get('this', data)
data = omit(['this'], data)
const params = concat(keys(data), UTIL_METHODS.KEYS)
const args = concat(values(data), UTIL_METHODS.VALUES)
const func = new Function(params, `return ${resolvedExpression}`)
let value = func.apply(self, args)
if (!exact) {
value = variableString.replace(match, value)
}
return value
}
const getParentIds = (component) => {
const parent = get('parent', component)
if (parent) {
return concat([get('instanceId', parent)], getParentIds(parent))
}
return []
}
(result, attribute) =>
concat(result, map((key) => ({ [key]: attribute[key] }), keys(attribute))),
[],
forEach((childValue, childKdx) => {
if (!isComponent(childValue)) {
const newKeys = concat(keys, [childKdx])
result = recur(result, childValue, newKeys, iteratee)
}
}, value)
}
forEach((childValue, childKdx) => {
const newKeys = concat(keys, [childKdx])
if (isComponent(childValue)) {
visited.add(childValue)
result = iteratee(result, childValue, newKeys)
} else {
result = recur(result, childValue, newKeys, iteratee)
}
}, value)
}
const getDependenciesIds = (component) =>
without(
union(getParentIds(component), [component.instanceId]),
union(
concat(getChildrenIds(component), getVariableInstanceIds(component)),
getComponentReferenceIds(component)
)
)
forEach((child, childKdx) => {
const newKeys = concat(keys, [childKdx])
result = recur(result, resolve(child), newKeys, iteratee)
}, children)
}