valid-iterable.js 566 B

12345678910111213141516171819202122232425262728
  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 () {
  7. t();
  8. }, TypeError, "Undefined");
  9. a.throws(function () {
  10. t({});
  11. }, TypeError, "Plain object");
  12. a.throws(function () {
  13. t({ length: 0 });
  14. }, TypeError, "Array-like");
  15. obj = {};
  16. obj[iteratorSymbol] = function () {
  17. return new Iterator([]);
  18. };
  19. a(t(obj), obj, "Iterator");
  20. obj = [];
  21. a(t(obj), obj, "Array");
  22. obj = (function () {
  23. return arguments;
  24. }());
  25. a(t(obj), obj, "Arguments");
  26. };