Mark Erikson
Aug 28, 2017 · 1 min read

A few quick thoughts.

First, you could simplify that deeply nested update just a bit by caching the lookup items at each level rather than writing the entire lookup chain each time. It would add a few more lines of code, but the lines for constructing the return structure would be easier to read.

Second, per other comments, we do recommend trying to normalize your data so that it isn’t deeply nested like this.

Third, using “reducer composition” and delegating the work is also an option for simplifying the process.

Finally, there are indeed dozens of existing immutable update utility libraries out there besides lodash/fp.

)

    Mark Erikson

    Written by