tc39 / proposal-flatMap

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

FlattenIntoArray: ensure `thisArg` is present or undefined #40

Closed ljharb closed 6 years ago

ljharb commented 6 years ago

Personally I'd prefer all the "is present" language be removed, but I'm not sure if it's necessary on the default args. If it is, then this change is needed; if it's not, then all the checks should be against undefined, not testing presence.

michaelficarra commented 6 years ago

@bterlson Do you know whether the "is present" checks are necessary here?

bterlson commented 6 years ago

I think technically yes given that the thisArg parameter is optional. However, I think the contract for this API is that if mapperFunction is passed, thisArg is always present. You could probably get away with making this an assert rather than applying the default.

ljharb commented 6 years ago

Either way; happy to change it to an assert instead.

michaelficarra commented 6 years ago

Cool. Let's make it an assertion.

ljharb commented 6 years ago

Updated.