Here's what I'm trying to do, but just can't get my head around...
Say I have the following files and folders in my project, where 'Folder3' is a subfolder of 'Folder2':
- Folder1
- File
- File
- File
- Folder2
- File
- File
- File
- Folder3
- File
- File
- File
What I want is create an object that will mirror that structure:
var listing = {
'Folder1' : {
'File',
'File',
'File'
}
'Folder2' : {
'File',
'File',
'File',
'Folder3' : {
'File',
'File'
}
}
}
I've looked at modules such as 'walk', but am not sure how to use them to create an object as described above. I've also looked at this question, but the top answer returns a one dimensional array, which isn't what I'm looking for.