@goodnight-dev/utils
    Preparing search index...
    • Test whether a given value is iterable. An iterable is any value that implements the Symbol.iterator method, allowing it to be used in a for...of loop or with the spread operator. Strings qualify alongside arrays, Map, Set, typed arrays, and generator objects.

      Parameters

      • value: unknown

        The value to test for iterability.

      Returns value is Iterable<unknown, any, any>

      true when the value is iterable; false otherwise. As a type guard, a true result narrows value to Iterable<unknown>, so it can be spread or driven with for...of without a cast.

      isIterable([1, 2, 3]) // => true
      isIterable('hello') // => true
      isIterable(new Map()) // => true
      isIterable(new Set()) // => true
      isIterable({ [Symbol.iterator]: function* () {} }) // => true
      isIterable({}) // => false
      isIterable(null) // => false
      isIterable(undefined) // => false