30-seconds-of-code: [REQUEST] Change name of isArrayLike

Created on 13 Aug 2018  路  4Comments  路  Source: 30-seconds/30-seconds-of-code



[REQUEST] Change isArrayLike name

Category: Request

Description


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.

Current Snippet Behavior



isArrayLike(iterable) === true for iterable defined as follows:

const iterable = {
  [Symbol.iterator]() {
    const iterator = { next() { return { value: undefined, done: true }; } };
    return iterator;
  }
}

Possible Solution



I recommend changing the name to isIterable

Most helpful comment

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.

All 4 comments

This would require changes to the library generation and may be breaking. There are two paths forward with that:

  1. Release tag and transition notifications
  2. Shim and rename

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kingdavidmartins picture kingdavidmartins  路  5Comments

fplgusmao picture fplgusmao  路  4Comments

Priyansh2001here picture Priyansh2001here  路  5Comments

larrybotha picture larrybotha  路  3Comments

Lucien-X picture Lucien-X  路  5Comments