Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Questions regarding "auto-flatten" an non-iterables #275

@benlesh

Description

@benlesh

Terribly sorry if this is clearly documented and I missed it

With Array#flatMap, it will automatically flatten/merge in values that are not arrays into the array output:

[1, 2, 3].flatMap(() => 42); // [42, 42, 42]

However, it will NOT auto convert any old iterable (I know this is a separate thing, just calling out the behavior):

[1, 2, 3].flatMap(() => new Set([42])) // [Set, Set, Set]

I'm using this information to help guide the direction of RxJS observables and our operators/methods long-term.

Questions

  1. What will happen in this scenario for any Iterable or AsyncIterable?
  2. What is the plan for this sort of support in any old Iterable or AsyncIterable? Will they flatten anything that implements Symbol.iterator or Symbol.asyncIterator respectively?
  3. Will this constitute a breaking change for Array#flatMap? Or is its implementation an Array-specific one-off from the iterator helpers?

Thank you in advance.

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