Frontmatter
| id | 1546 |
| title | util.Array: removeAdd() convenience method |
| state | Closed |
| labels | enhancement |
| assignees | tobiu |
| createdAt | Mar 18, 2021, 12:39 AM |
| updatedAt | Mar 18, 2021, 12:41 AM |
| githubUrl | https://github.com/neomjs/neo/issues/1546 |
| author | tobiu |
| commentsCount | 0 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 18, 2021, 12:41 AM |
I am using
remove()andadd()in combination a lot, so a convenience method to combine the calls makes sense.e.g.:
to keep it simple:
static removeAdd(arr, removeItems, addItems) { this.remove(arr, removeItems); this.add(arr, addItems); }I am not calling the method
replace(), since this would indicate that items get replaced at its index and probably new items would only get added in case the item to replace exists.feel free to open a new ticket in case you need a "real"
replace()method.