babel/lib/6to5/transformation/templates/sliced-to-array.js
2015-02-13 20:38:28 +11:00

15 lines
410 B
JavaScript

(function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in arr) {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
});