Category: Request
isArrayLike does not clearly describle its purpose. Its own description has to clarify what isArrayLike means:
[isArrayLike]: "Checks if the provided argument is array-like (i.e. is iterable).
This description itself recommends a different name - isIterable.
isArrayLike(iterable) === true for iterable defined as follows:
const iterable = {
[Symbol.iterator]() {
const iterator = { next() { return { value: undefined, done: true }; } };
return iterator;
}
}
I recommend changing the name to isIterable
This would require changes to the library generation and may be breaking. There are two paths forward with that:
For compatibility shim and rename would be best.
As for my opinion on the title:
isArrayLike needs an updated description if nothing else. It should just say
Checks if the provided argument is an iterable
As for the name it should be noted that this is common in other libraries and was actually adapted from one. This is most likely due to legacy reasons as before in those libraries they just checked if there was a length property. We updated when we adapted it from lodash it was updated to check for more general cases. isArrayLike may be more relatable for the vast majority of programmers regardless of language since it's the most common. It sucks in getting the idea across, but does a good job at introducing a new phrase to google.
isArrayLike is definitely more approachable to most programmers than isIterable as people look for things that behave like arrays, not things that are iterable. In a perfect world, isIterable would feel a lot more intuitive. This is not a perfect world.
@Chalarangelo Sounds reasonable to me. Thanks to both of you for taking the time.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for any follow-up tasks.
Most helpful comment
isArrayLikeis definitely more approachable to most programmers thanisIterableas people look for things that behave like arrays, not things that are iterable. In a perfect world,isIterablewould feel a lot more intuitive. This is not a perfect world.