0.0.3 • Published 7 years ago

bianco.is-iterable v0.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

bianco.is-iterable

Build Status

NPM version NPM downloads MIT License

Usage

import isIterable from 'bianco.is-iterable'

// An array should be iterable
const arr = [1, 2, 3]
isIterable(arr) // => true of course

// A generator should be iterable
const gen = (function *() {
  yield Math.random()
})()
isIterable(gen) // => true

// A DOM nodes list should be iterable
const lis = document.querySelectorAll('li')
isIterable(lis)  // => depends on the browser

// An object should not be iterable
const obj = { foo: 'foo', bar: 'bar' }
isIterable(obj) // => false

API

  • isIterable returns true if the object could be looped in a "for of" otherwise false