typescript object util library
Is there any good typescript library for object manipulation? Ie changing values of deeply nested objects, getting values via dot notation keys. Setting via dot notation etc
5 Replies
Do you really need a library for that?
That's basic JS language stuff... what would a library for that even DO?
Doesn’t seem like accessing object via “property.x.b.c” is basic language stuff.
My question might be misleading a little bit. I was referring to string dot notation keys. Sorry
Particularly I need to flatten keys of deeply nested objects to strings and being able to set/get/pick via string keys
That seems like a VERY niche and you-specific use case. Even if a library does exist for it, you should write this component yourself
Remeda has this stuff, but uses string arrays. look at
pathOr
and set
. I would recommend this approach, it's the best utility lib by far IMO.
If you absolutely need to use dot notation and can't split the keys yourself, lodash offers this.
and hard disagree on writing yourself. so many edge cases, why not use something battle tested...