@@ -10,24 +10,28 @@ const FILE_PATH_DELIMITER = /[\/\\]+/ // eslint-disable-line
10
10
*/
11
11
const ENDS_WITH_DELIMITER = / [ \/ \\ ] $ / // eslint-disable-line
12
12
13
+ /**
14
+ * @typedef {{
15
+ * file: boolean
16
+ * name: string
17
+ * id: string
18
+ * path?: Object // Original path object that may contain properties like caspar, data, etc.
19
+ * }} File
20
+ *
21
+ * @typedef {{
22
+ * file: boolean
23
+ * name: string
24
+ * id: string
25
+ * files?: Folder[] // Nested files or folders
26
+ * }} Folder
27
+ */
28
+
13
29
/**
14
30
* Converts a list of file paths into a nested folder structure.
15
31
* The function assumes that paths are strings with folders and files separated by '/' or '\'.
16
- *
17
- * @typedef {Object } File
18
- * @property {boolean } file - A flag indicating whether the object is a file (true) or a folder (false).
19
- * @property {string } name - The full path as a string (e.g., 'folder1/folder2/item').
20
- * @property {string } id - A unique identifier.
21
- * @property {Object } [path] - The original path object that contains additional properties such as caspar, data etc.
22
- *
23
- * @typedef {Object } Folder
24
- * @property {boolean } file - A flag indicating whether the object is a file (true) or a folder (false).
25
- * @property {string } name - The name of the file/folder.
26
- * @property {string } id - A unique identifier.
27
- * @property {Array[] } [files] - An array of nested files/folders.
28
32
*
29
- * @param {Array[] } paths - An array of path objects, where each object contains at least a `name` property with the full path .
30
- * @returns {Folder[] } - A nested folder structure represented as an array of folder objects.
33
+ * @param {{ name: string, [key: string]: any }[] } paths - An array of path objects with at least a `name` string .
34
+ * @returns {Folder[Folder|File ] } - A nested folder structure represented as an array of folder objects.
31
35
* @example
32
36
* Input: [{ path.name: 'folder1/item' }]
33
37
* Output: [
0 commit comments