mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Simplify getting of composite paths
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
f2e6ce22aa
commit
9f19fdceb2
@ -3,26 +3,10 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { pipeline } from "@ogre-tools/fp";
|
||||
import { flatMap } from "lodash/fp";
|
||||
import { map } from "lodash/fp";
|
||||
import type { Composite } from "../get-composite";
|
||||
import { normalizeComposite } from "../normalize-composite/normalize-composite";
|
||||
|
||||
export const getCompositePaths = (
|
||||
composite: Composite<any>,
|
||||
previousPath: string[] = [],
|
||||
): string[] => {
|
||||
const currentPath = [...previousPath, composite.id];
|
||||
|
||||
const currentPathString = currentPath.join(".");
|
||||
|
||||
return [
|
||||
currentPathString,
|
||||
|
||||
...pipeline(
|
||||
composite.children,
|
||||
|
||||
flatMap((childComposite) =>
|
||||
getCompositePaths(childComposite, currentPath),
|
||||
),
|
||||
),
|
||||
];
|
||||
};
|
||||
composite: Composite<unknown>,
|
||||
): string[] => pipeline(composite, normalizeComposite, map(([path]) => path));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user