From c6ce1a248c1f2ca5d92664cd17afed56fb6602fe Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 13 Feb 2015 20:38:28 +1100 Subject: [PATCH] better slicedToArray helper --- lib/6to5/transformation/templates/sliced-to-array.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/6to5/transformation/templates/sliced-to-array.js b/lib/6to5/transformation/templates/sliced-to-array.js index af2f04e8e7..3ef086127c 100644 --- a/lib/6to5/transformation/templates/sliced-to-array.js +++ b/lib/6to5/transformation/templates/sliced-to-array.js @@ -1,14 +1,14 @@ (function (arr, i) { - if (!arr || !arr[Symbol.iterator]) { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - } else if (Array.isArray(arr)) { + if (Array.isArray(arr)) { return arr; - } else { + } 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"); } });