get.js 459 B

12345678910111213
  1. 'use strict';
  2. var isString = require('es5-ext/string/is-string')
  3. , ArrayIterator = require('./array')
  4. , StringIterator = require('./string')
  5. , iterable = require('./valid-iterable')
  6. , iteratorSymbol = require('es6-symbol').iterator;
  7. module.exports = function (obj) {
  8. if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol]();
  9. if (isString(obj)) return new StringIterator(obj);
  10. return new ArrayIterator(obj);
  11. };