Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

get the index of a key in an OrderedMap #1423

Copy link
Copy link
Open
@ianstormtaylor

Description

@ianstormtaylor
Issue body actions

Hey, an idea... when dealing with ordered maps, it seems like it would be a common use case to be able to retrieve the index of an item by key, so that you can create subsets of the ordered map using slice() or similar.

Basically right now to slice an ordered map by key, I believe you have to iterate the key sequence first to figure out what index the key lives at, like so:

const index = orderedMap.keySeq().findIndex(k => k === key)

But this seems like it makes slice(), etc by key much slower. Although it's a tradeoff of manipulation time vs. write time.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.