1
0
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:
Iku-turso 2022-10-12 09:17:37 +03:00 committed by Janne Savolainen
parent f2e6ce22aa
commit 9f19fdceb2
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A

View File

@ -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));