mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
break down foldername into subpaths
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { subPath } from "@/interfaces";
|
||||
|
||||
/**
|
||||
* Breaks a path into sub-paths.
|
||||
* @param {string} paths to break into subpaths
|
||||
* @returns {subPath[]} an array of subpaths
|
||||
*/
|
||||
export default function createSubPaths(paths: string | string[]): subPath[] {
|
||||
const pathlist = (paths as string).split("/");
|
||||
pathlist.shift();
|
||||
|
||||
const subPaths = pathlist.map((path, index) => {
|
||||
return { name: path, path: pathlist.slice(0, index + 1).join("/") };
|
||||
});
|
||||
|
||||
return subPaths;
|
||||
}
|
||||
Reference in New Issue
Block a user