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

insertAtIndex renaming to replaceAtIndex or logic update #47

Open
AdrianFiroiu opened this issue Jun 17, 2021 · 1 comment
Open

insertAtIndex renaming to replaceAtIndex or logic update #47

AdrianFiroiu opened this issue Jun 17, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@AdrianFiroiu
Copy link
Member

As @kuserich mentioned in PR #41, we should consider adjusting the current implementation of the insertAtIndex, rename it or rename and add insertAtIndex.

To me, "insertAtIndex" implies that we are adding an element to an array while keeping all original items.
Thus, I would be in favour of renaming this function to replaceAtIndex or update its logic.

insertAtIndex( [ 'a', 'd', 'c' ], 'b', 1 );

// => Array [ 'a', 'b', 'd', 'c' ]

or

replaceAtIndex( [ 'a', 'd', 'c' ], 'b', 1 );

// => Array [ 'a', 'b', 'c' ]

or, since i assume we are using it already, rename and add insertAtIndex. what do you think @mahdiyazdani @gooklani ?

@AdrianFiroiu AdrianFiroiu added the enhancement New feature or request label Jun 17, 2021
@mahdiyazdani
Copy link
Contributor

I agree with @kuserich that naming could be improved by renaming this method to replaceAtIndex or something similar. However, this method has been used across multiple blocks/extensions which would require manual inspection and update if decided to go forward with this.

On the other hand, I would be in favor of introducing another method that does the job of inserting an element into an array at a given index.

The idea behind the existing method initially being inspired by this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants