valid-iterable.js 485 B

12345678910111213141516
  1. 'use strict';
  2. var iteratorSymbol = require('es6-symbol').iterator
  3. , Iterator = require('../');
  4. module.exports = function (t, a) {
  5. var obj;
  6. a.throws(function () { t(); }, TypeError, "Undefined");
  7. a.throws(function () { t({}); }, TypeError, "Plain object");
  8. a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like");
  9. obj = {};
  10. obj[iteratorSymbol] = function () { return new Iterator([]); };
  11. a(t(obj), obj, "Iterator");
  12. obj = [];
  13. a(t(obj), obj, 'Array');
  14. };