The Wayback Machine - https://web.archive.org/web/20240219141855/https://github.com/lodash/lodash/issues/4865
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

Expand _.pullAt to take negative index #4865

Closed
lonewarrior556 opened this issue Jul 18, 2020 · 2 comments
Closed

Expand _.pullAt to take negative index #4865

lonewarrior556 opened this issue Jul 18, 2020 · 2 comments
Labels
change issue bankruptcy Closing the issue/PR to start fresh

Comments

@lonewarrior556
Copy link

lonewarrior556 commented Jul 18, 2020

Make _.pullAt consistent with _.nth

var array = ['a', 'b', 'c', 'd'];
 
_.nth(array, 1);
// => 'b'
 
_.nth(array, -2);
// => 'c';

/* Current Behavior of pullAt*/
_.pullAt(array,[1,-2]) 
// => ["b", undefined]

/* Should be */
_.pullAt(array,[1,-2]) 
// => ["b", "c"]

This would make finding the Bounds of an array simpler

_.pullAt(_.sortBy([9,1,8,2,6,4,9,11,1,0,50,1,2,3,4]), 0, -1)
// => [0, 50]
@lonewarrior556 lonewarrior556 changed the title Expand _.pullAt to take negative index Expand _.at _.pullAt to take negative index Jul 18, 2020
@bnjmnt4n
Copy link
Member

_.at is an Object method, meaning it is designed to work on objects primarily. Adding this special handling of negative numbers will does not seem like a good idea for _.at, and for consistency, we might also not want to change _.pullAt.

@lonewarrior556 lonewarrior556 changed the title Expand _.at _.pullAt to take negative index Expand _.pullAt to take negative index Dec 21, 2020
@lonewarrior556
Copy link
Author

lonewarrior556 commented Dec 21, 2020

@bnjmnt4n updated request to only modify Array: _.pullAt

_.pullAt is already inconsistent with _.at as it mutates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change issue bankruptcy Closing the issue/PR to start fresh
Development

No branches or pull requests

3 participants