createForOfIteratorHelper.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import unsupportedIterableToArray from "./unsupportedIterableToArray.js";
  2. export default function _createForOfIteratorHelper(o, allowArrayLike) {
  3. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  4. if (!it) {
  5. if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  6. if (it) o = it;
  7. var i = 0;
  8. var F = function F() {};
  9. return {
  10. s: F,
  11. n: function n() {
  12. if (i >= o.length) return {
  13. done: true
  14. };
  15. return {
  16. done: false,
  17. value: o[i++]
  18. };
  19. },
  20. e: function e(_e) {
  21. throw _e;
  22. },
  23. f: F
  24. };
  25. }
  26. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  27. }
  28. var normalCompletion = true,
  29. didErr = false,
  30. err;
  31. return {
  32. s: function s() {
  33. it = it.call(o);
  34. },
  35. n: function n() {
  36. var step = it.next();
  37. normalCompletion = step.done;
  38. return step;
  39. },
  40. e: function e(_e2) {
  41. didErr = true;
  42. err = _e2;
  43. },
  44. f: function f() {
  45. try {
  46. if (!normalCompletion && it["return"] != null) it["return"]();
  47. } finally {
  48. if (didErr) throw err;
  49. }
  50. }
  51. };
  52. }