icepick icon indicating copy to clipboard operation
icepick copied to clipboard

Generic "in" operator

Open tlrobinson opened this issue 6 years ago • 1 comments

I find assocIn etc to be useful, and sometimes wish similar functions existed for the other functions. Here's a prototype of an at (because in is a reserved word) function and chain method that let you apply any operator to a path:

https://runkit.com/tlrobinson/5dc341aa7f9859001a1b54f4

e.x.

icepick.at(object, ["foo", "bar"]).push(4)

icepick.chain(object)
  .at(["foo", "bar"]).push(4)
  .at(["new", "object"]).assoc(5)
  .at(["new", "array"]).push(6)
  .value()

tlrobinson avatar Nov 06 '19 22:11 tlrobinson

I like this feature, seems very handy. Seems like it could be implemented similarly to .chain() too.

aearly avatar Nov 10 '19 23:11 aearly