is-iterable.js 556 B

12345678910111213141516
  1. var classof = require('../internals/classof');
  2. var hasOwn = require('../internals/has-own-property');
  3. var isNullOrUndefined = require('../internals/is-null-or-undefined');
  4. var wellKnownSymbol = require('../internals/well-known-symbol');
  5. var Iterators = require('../internals/iterators');
  6. var ITERATOR = wellKnownSymbol('iterator');
  7. var $Object = Object;
  8. module.exports = function (it) {
  9. if (isNullOrUndefined(it)) return false;
  10. var O = $Object(it);
  11. return O[ITERATOR] !== undefined
  12. || '@@iterator' in O
  13. || hasOwn(Iterators, classof(O));
  14. };