Skip to content
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

Add the merge and removeBatch mutators #27

Merged
merged 2 commits into from
Jul 12, 2019

Conversation

lucasveigaf
Copy link
Contributor

Adds two new mutators: merge for merging an array with the existing field array. removeBatch for removing items from the field array given a list of indexes.

See #26

@codecov
Copy link

codecov bot commented Apr 23, 2019

Codecov Report

Merging #27 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #27   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           9     11    +2     
  Lines          84    101   +17     
  Branches       16     19    +3     
=====================================
+ Hits           84    101   +17
Impacted Files Coverage Δ
src/merge.js 100% <100%> (ø)
src/removeBatch.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1df13c...8452759. Read the comment docs.

changeValue(
state,
name,
(array: ?(any[])): ?(any[]) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could simply be:
array => array && indexes ? array.filter((item, i) => !indexes.includes(i)) : array

Although much simpler, the performance is significantly worse. Not sure what should be the goal here, since probably there won't be hundreds/thousands of item in the field array.

Any thoughts?

@erikras
Copy link
Member

erikras commented Jul 12, 2019

merge should be concat to follow the JavaScript nomenclature.

I'm working on this library today, so I'll merge (😆) this PR and rename it.

@erikras erikras merged commit 9345846 into final-form:master Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants