is-iterable.js 568 B

1234567891011121314151617181920212223
  1. "use strict";
  2. var iteratorSymbol = require("es6-symbol").iterator
  3. , Iterator = require("../");
  4. module.exports = function (t, a) {
  5. var iterator;
  6. a(t(), false, "Undefined");
  7. a(t(123), false, "Number");
  8. a(t({}), false, "Plain object");
  9. a(t({ length: 0 }), false, "Array-like");
  10. iterator = {};
  11. iterator[iteratorSymbol] = function () {
  12. return new Iterator([]);
  13. };
  14. a(t(iterator), true, "Iterator");
  15. a(t([]), true, "Array");
  16. a(t("foo"), true, "String");
  17. a(t(""), true, "Empty string");
  18. a(t(function () {
  19. return arguments;
  20. }()), true, "Arguments");
  21. };