is-iterable.js 570 B

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