Skip to content

Array#filterMap #12

Open
Open
@lukescott

Description

@lukescott

With flatMap added with flat to reduce iterations and allocations, it would be nice to have an accompanying filterMap method as well. I often find filter and map used together.

Something like this:

[{active: true, label: "foo"}, {active: true, label: "bar"}]
  .filter(v => v.active)
  .map(v => v.label)

Could be written as:

[{active: true, label: "foo"}, {active: true, label: "bar"}]
  .filterMap(v => v.active && v.label)

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