Skip to content

[collections] Pass index to partition callback #6288

Open
@canac

Description

@canac

Is your feature request related to a problem? Please describe.

I tried to use partition and expected to be able to access the element index like normal array methods, but it isn't passed to the callback.

Describe the solution you'd like

Pass the element index to the partition callback. If the maintainers think this is a good idea, there are other methods in collections that could be passed the index as well. Maybe we should even consider passing in the original array as the third argument to match the signature of most built-in array method callbacks. EDIT: I noticed that most methods accept iterables so passing in the original array does not make sense.

Describe alternatives you've considered

Call .filter twice to partition the array instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions