importisIterablefrom'bianco.is-iterable'// An array should be iterableconstarr= [1, 2, 3]
isIterable(arr) // => true of course// A generator should be iterableconstgen= (function*() {
yieldMath.random()
})()
isIterable(gen) // => true// A DOM nodes list should be iterableconstlis=document.querySelectorAll('li')
isIterable(lis) // => depends on the browser// An object should not be iterableconstobj= { foo:'foo', bar:'bar' }
isIterable(obj) // => false
API
isIterable returns true if the object could be looped in a "for of" otherwise false