tc39 / proposal-flatMap

proposal for flatten and flatMap on arrays
https://tc39.github.io/proposal-flatMap
214 stars 19 forks source link

`mapper` is never used #46

Closed bga closed 6 years ago

bga commented 6 years ago

do you want to clone https://apidock.com/ruby/Enumerable/flat_map ?

bga commented 6 years ago

in Ruby there are Array#flatten(deep = +Infinity) and Array#flat_map(mapper) (always infinite deep coz how to deal with array leafs - transform via mapper or leave as is or may be go deeper and map but leave nested structure)

ljharb commented 6 years ago

The mapper argument is certainly used in the wild; what is this issue about, exactly?

bga commented 6 years ago

i assume Array#flatten(deep = +Infinity, mapper = null, thisArg =null) would be optimal to avoid 2nd map(mapper) chain call

michaelficarra commented 6 years ago

I have no idea what is going on in this thread.

ljharb commented 6 years ago

@bga “flatten” and “flatMap” have been intentionally chosen for this proposal with their current APIs. An API with an optional callback and an optional thisArg is unlikely to fly, and has no precedent I’m aware of in the language.

Why did you file this issue?

bga commented 6 years ago

Ok. I dont know what is current API you talking about (lodash?). Just remove anything related mapper to avoid questions from other ppl.

ljharb commented 6 years ago

flatMap takes a mapper function callback, and will continue to do so. flatten does not (it only takes a depth).