All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sagas.widgetDependency.getWidgetDependency.ts Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
import map from 'lodash/map'

import { sortDependency } from './sortDependency'
import { Dependencies, WidgetsDependencies } from './WidgetTypes'

export function getWidgetDependency(
    widgetsDependencies: WidgetsDependencies,
    widgetId: string,
    dependency: Dependencies,
) {
    if (dependency) {
        const parents: string[] = []

        dependency = sortDependency(dependency)

        map(dependency, (dep) => {
            map(dep, (d) => {
                if (d.on) {
                    parents.push(d.on)
                }
            })
        })

        return {
            ...widgetsDependencies,
            [widgetId]: {
                widgetId,
                dependency,
                parents,
            },
        }
    }

    return widgetsDependencies
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy