DEV Community

Discussion on: Immutability in JavaScript

Collapse
 
stevenlangbroek profile image
Steven Langbroek • Edited

That's great! Took a cursory look at the code, and if you'd reversed the argument order, you could've delegated to pipe (maybe a more familiar name for people?) and compose (right-associative version of pipe) from lodash, ramda or whatever. The problem now is, what if I'm already piping a bunch of unary functions using any of the bigger FP toolbelts, and add a immutadot function? It won't work:

const newState = pipe(
  over('items', filter(has('id')),
  // won't work
  push('items', newItem)
)(oldState);