[ https://issues.apache.org/jira/browse/SLING-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13912029#comment-13912029 ]
Francesco Mari commented on SLING-3413: --------------------------------------- In my opinion is not a common idiom in JavaScript to terminate the iteration earlier. It is better to use function composition to filter or map input lists and do something once you have transformed the input data in what you really need. As an alternative, you can use the chain pattern instead of function composition. In example: {code} resource.forEachChild(print) // print each children resource.filterChildren(hasNameProperty).forEachChild(print) // print only children having a name property resource.mapChildren(getNameProperty).toArray() // create an array of strings, the name properties of the child nodes {code} In this case {{print}}, {{hasNameProperty}} and {{getNameProperty}} are all filtering and mapping functions. > add support for getName() and listChildren() to JS Resource API > --------------------------------------------------------------- > > Key: SLING-3413 > URL: https://issues.apache.org/jira/browse/SLING-3413 > Project: Sling > Issue Type: Improvement > Components: Scripting > Reporter: Justin Edelson > Fix For: Scripting JavaScript 2.0.14 > > > The JS API used to wrap Resources doesn't support getting a list of children > or the resource's name as these methods on the Resource interface post-date > the last update to the JS API. The JS API should be brought up to date. -- This message was sent by Atlassian JIRA (v6.1.5#6160)