import Immutable from "immutable" ; import THEME_PREFIX from "../constants/themePrefix" ; const TYPE_PLUGIN = "plugin" ; const TYPE_THEME = "theme" ; param { Plugin } plugin return { string } function pluginType ( plugin ) { const name = plugin . getName ( ) ; return name && name . indexOf ( THEME_PREFIX ) === 0 ? TYPE_THEME : TYPE_PLUGIN ; } param { List < PluginDependency > } deps return { List < PluginDependency > } function sortDependencies ( plugins ) { const byTypes = plugins . groupBy ( pluginType ) ; return byTypes . get ( TYPE_PLUGIN , Immutable . List ( ) ) . concat ( byTypes . get ( TYPE_THEME , Immutable . List ( ) ) ) ; } export default sortDependencies ;