Repository URL to install this package:
|
Version:
3.12.2 ▾
|
import createFoldervirtualPath from './createFolderVirtualPath';
import removeEmptyFolders from './removeEmptyFolders';
/**
* Util used to add vitual pathes to sharebox folders
* @property { _folders } array
* @property { parentPath } string
* @returns { folderWithPath }
*/
var injectVirtualPathToFolders = function injectVirtualPathToFolders() {
var _folders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var parentPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return _folders.map(function (folder) {
var folderWithPath = createFoldervirtualPath(folder, parentPath);
var subFolders = folder.folders;
if (subFolders) {
var nonEmptySubFolders = removeEmptyFolders(subFolders);
folderWithPath.folders = injectVirtualPathToFolders(nonEmptySubFolders, folderWithPath.path);
}
return folderWithPath;
});
};
export default injectVirtualPathToFolders;