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

Description
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
- What will happen in this scenario for any
Iterable or AsyncIterable?
- 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?
- 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.