-
Notifications
You must be signed in to change notification settings
8000
- Fork 7.1k
Support for replacement in array #1967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks @jfmengels! We'll keep an eye on the popularity of the request. Side note: |
Agreed on the signature (updated it), it's what I was using in the examples actually. |
+1 for this feature I'd also find it useful to have the possibility to add multiple elements at a given array index (immutable splice) |
This would be really useful in reactjs to update an array in the |
+1 for this feature. In our cases we need to maintain an array(or could be an object) of the app's tabs status in Redux like this: const initialState = Immutable.from({
selected: [
{ page: Pages.NEWS, active: true, tabs: [
{ tab: Tabs.HOTTEST, active: false, subTabs: []},
{ tab: Tabs.HISTORY, active: true, subTabs: []},
{ tab: Tabs.RECOMMENDATIONS, active: false, subTabs: []},
]},
{ page: Pages.VIDEOS, active: false, tabs: []},
],
}) While an Using other data structure might help in our case but I'm just posting the possible situation we've been met where |
Hello guys, so I was curious... Is it currently possible to do something like this in lodash? Or we still have to use our own util function across projects (basic example):
Because what's the process? Suggestions are made, tags like |
Bump. I find myself needing this a lot and would very much like to see this feature. |
Hi, please forgive if "bump+1" comments on issues is the wrong kind of vote (per your docs), and do not want to appear entitled, but am not sure anyways given the radio silence - so I'm adding both. Apologies if my doing so on several diff issues constitutes spam ( I genuinely am not sure and not intending it to be! ) |
I am often (in multiple projects) reimplementing the same utility function, that replaces a value in an array based on some condition (a position or a field is equal to X), without mutating the original array (like
map
in that regard):I would like to dip my toe in the water and see if others would be interested in having a function that does this.
Example
I would have liked it to be named
replace
, but since that is already taken... ^^'I used
mapReplace
in the example but open to suggestions.I'd argue it would be nice to have one function to update the first found item, and one to update them all (kind of like the proposal for
replaceAll
).The text was updated successfully, but these errors were encountered: