Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F105068998
findSection.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Mar 14, 12:03
Size
713 B
Mime Type
text/x-java
Expires
Sun, Mar 16, 12:03 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24882605
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
findSection.js
View Options
import find from 'lodash/find';
/**
* Recursively finds a section with a given name (exact match)
*
* @param {Array} sections
* @param {string} name
* @return {object}
*/
export default function findSection(sections, name) {
// We're using Lodash because IE11 doesn't support Array.find.
var found = find(sections, {
name: name
});
if (found) {
return found;
}
for (var i = 0; i < sections.length; i++) {
var section = sections[i];
if (!section.sections || section.sections.length === 0) {
continue;
}
var foundInSubsection = findSection(section.sections, name);
if (foundInSubsection) {
return foundInSubsection;
}
}
return undefined;
}
Event Timeline
Log In to Comment