How to write inexpensive pure functions in javascript?

This page summarizes the projects mentioned and recommended in the original post on /r/functionalprogramming

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • ramda

    :ram: Practical functional Javascript

  • 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.

  • Immer

    Create the next immutable state by mutating the current one

  • 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.

  • 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.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts