Does lodash have functions for constructing (i.e. building brick by brick) an object? #5865
Unanswered
tomerh2001
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I've encountered this need a lot, and lately, I've been toying with the idea of opening a PR about it. But before I do, I want to make sure there really isn't a way of doing what I need using pure Lodash.
Case 1
Functionally add/set a field to an object. We expand on this in case 2.
Case 2
Expanding on case 1, functionally add/set a field based on the object's current values:
Case 3
Expanding on case 2, applying the extend function to each object in an array:
I know there's an existing
extendfunction that modifies the target object in place instead of creating a new object. It also doesn't support dynamic assignment (case 2) or an array equivalent (case 3).If I would proceed with creating a PR, maybe adding a differently named function will be more fitting.
Beta Was this translation helpful? Give feedback.
All reactions