Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
That said, what it looks like you're doing may be done with Array.prototype.reduce where you can attempt to do you entire pipeline of operations on each element (unless they're not mutually exclusive) all in a single pass, even excluding elements that don't pass a particular filter. The reducer callback that you employ can employ other reducers, too. This sounds very similar to writing a JSON parser to me -- recursive parsing of nested hashes or other collections. I've done this in a functional language before. If you're not opposed to an abstraction, there is RamdaJS - https://ramdajs.com/. I enjoyed tinkering with it when I was still doing JavaScript, and have seen it pop up from time to time.
It’s harder to write more functional code without the right tools. JavaScript is okay as a functional language (better than most tbh), but is missing some key components like immutable data structures. You might checkout Immer or Immutable.js to fill this gap.