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 moveIndex #470

Open
cjquines opened this issue Jan 21, 2024 · 3 comments
Open

Add moveIndex #470

cjquines opened this issue Jan 21, 2024 · 3 comments
Labels
feature request New feature or request good first issue Good for newcomers

Comments

@cjquines
Copy link
Collaborator

Equivalent to move from Ramda; the most requested function in Lodash.

The one-liner R.moveIndex(data, from, to) would be data.toSpliced(from, 1).toSpliced(to, 0, data[from]), but this would also have R.moveIndex.strict, like R.swapIndices.strict, which is another reason to have this function in Remeda proper.

@eranhirsch
Copy link
Collaborator

I'm cool with a moveItem function.

but this would also have R.moveIndex.strict, like R.swapIndices.strict, which is another reason to have this function in Remeda proper.

I couldn't find a swapIndices.strict in Remeda, what did you mean by this?

@eranhirsch eranhirsch added feature request New feature or request good first issue Good for newcomers labels Feb 12, 2024
@cjquines
Copy link
Collaborator Author

cjquines commented Feb 13, 2024

oops, i thought we had a swapIndices.strict. i was referring to the fact that swapIndices was typed for tuples:

expectTypeOf(swapIndices([2, 'a'], 0, 1)).toEqualTypeOf<[string, number]>();

a hypothetical moveItem should also be like this:

expectTypeOf(moveItem([2, 'a'], 0, 1)).toEqualTypeOf<[string, number]>();

@eranhirsch
Copy link
Collaborator

Yea, it should provide good typing for tuples

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

No branches or pull requests

2 participants