mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
5a3318f5b3
simple iterable paths GitOrigin-RevId: f6906016888ccfc95c88858bdac4d2633fc1c5f4
15 lines
304 B
JavaScript
15 lines
304 B
JavaScript
/**
|
|
* Handles malformed filetrees - when fields such as `folder.docs`,
|
|
* `folder.folders` or `folder.fileRefs` are missing it returns an
|
|
* empty array.
|
|
*/
|
|
function iterablePaths(folder, field) {
|
|
if (!folder) {
|
|
return []
|
|
}
|
|
return folder[field] || []
|
|
}
|
|
|
|
module.exports = {
|
|
iterablePaths,
|
|
}
|