overleaf/services/web/app/src/Features/Project/IterablePath.js
Brian Gough 5a3318f5b3 Merge pull request #8701 from overleaf/bg-simple-iterable-paths
simple iterable paths

GitOrigin-RevId: f6906016888ccfc95c88858bdac4d2633fc1c5f4
2022-07-05 08:03:43 +00:00

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,
}