tc39/proposal-array-filtering

.filterReject or .filterOut?

Opened this issue ยท 8 comments

In the presentation, I see the new name, but in the proposal repo, I don't see any mentioning of that. So, it's changed?

If it was decided to use filterReject, why not simplify to a short name reject similar to lodash?

A few people have reached out to say that they don't like the name filterOut, so I'm proposing filterReject in the slides to see if that's more agreeable. I'll update the README, since this is the second time that it's confused someone.

If it was decided to use filterReject, why not simplify to a short name reject similar to lodash?

That's another possibility, but it solves only the functional utility of inverse filtering. The name filterX and specifically filterReject is meant to be as close as possible to filter, so that they can be learned as pairs. By learning about filterReject and giving it a self-describing name, I can learn that it behaves the way I intuit filtering to work (reject the item under test). And because they're so closely named, I can learn that filter does the opposite (select the item under test).

.filterReject seems too cumbersome to me.

I'm open to renaming, but I strongly prefer a name matching filterX for the reasons stated above.

Pro filterOut for one verb.

+1 for filterOut

"out" is used as an adverb here, so "filter out" is a verb phrase.
"reject" is another verb (in addition to the verb "filter") so "filter reject" doesn't parse in English.

numbers.filterOut(isOdd) is very close to how I would read it out in English: "numbers with the odd ones filtered out".

A few people have reached out to say that they don't like the name filterOut

@jridgewell I'm curious.. why they didn't like it?

I'm curious.. why they didn't like it?

In my opinion, filterOut is too similar to filterOutput. filterOut is sometimes used as an abbreviation of filterOutput, much like out is sometimes used as an abbreviation of output. My concern is: a statement applying a negated filter operation over some values could easily be misunderstood to be applying a regular filter operation over output values.