slicedToArray.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. exports.__esModule = true;
  3. var _isIterable2 = require("../core-js/is-iterable");
  4. var _isIterable3 = _interopRequireDefault(_isIterable2);
  5. var _getIterator2 = require("../core-js/get-iterator");
  6. var _getIterator3 = _interopRequireDefault(_getIterator2);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. exports.default = function () {
  9. function sliceIterator(arr, i) {
  10. var _arr = [];
  11. var _n = true;
  12. var _d = false;
  13. var _e = undefined;
  14. try {
  15. for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) {
  16. _arr.push(_s.value);
  17. if (i && _arr.length === i) break;
  18. }
  19. } catch (err) {
  20. _d = true;
  21. _e = err;
  22. } finally {
  23. try {
  24. if (!_n && _i["return"]) _i["return"]();
  25. } finally {
  26. if (_d) throw _e;
  27. }
  28. }
  29. return _arr;
  30. }
  31. return function (arr, i) {
  32. if (Array.isArray(arr)) {
  33. return arr;
  34. } else if ((0, _isIterable3.default)(Object(arr))) {
  35. return sliceIterator(arr, i);
  36. } else {
  37. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  38. }
  39. };
  40. }();