properly support iterators in sliced-to-array helper...
This commit is contained in:
@@ -2,10 +2,35 @@
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
} else if (Symbol.iterator in Object(arr)) {
|
||||
// this is an expanded form of `for...of` that properly supports abrupt completions of
|
||||
// iterators etc. variable names have been minimised to reduce the size of this massive
|
||||
// helper. sometimes spec compliancy is annoying :()
|
||||
//
|
||||
// _n = _iteratorNormalCompletion
|
||||
// _d = _didIteratorError
|
||||
// _e = _iteratorError
|
||||
// _i = _iterator
|
||||
// _s = _step
|
||||
|
||||
var _arr = [];
|
||||
for (var val of arr) {
|
||||
_arr.push(_step.value);
|
||||
if (i && _arr.length === i) break;
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n (_s = _i.next()).done); _n = true) {
|
||||
var val = _s.value;
|
||||
_arr.push(_step.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"]) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user