parent
63cd9013cc
commit
43dabf5cbd
|
@ -21,17 +21,14 @@
|
||||||
var arrayPrototype = Array.prototype;
|
var arrayPrototype = Array.prototype;
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
var iteratorSymbol = typeof Symbol != 'undefined' && Symbol.iterator;
|
|
||||||
var iteratorPrototype = {};
|
var iteratorPrototype = {};
|
||||||
|
|
||||||
if (iteratorSymbol) {
|
|
||||||
// These iterators should themselves be iterable.
|
// These iterators should themselves be iterable.
|
||||||
Object.defineProperty(iteratorPrototype, iteratorSymbol, {
|
Object.defineProperty(iteratorPrototype, Symbol.iterator, {
|
||||||
value: function() {
|
value: function() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'join',
|
'join',
|
||||||
|
@ -86,6 +83,4 @@ if (iteratorSymbol) {
|
||||||
exports[methodName] = {value: method, configurable: true, writable: true};
|
exports[methodName] = {value: method, configurable: true, writable: true};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (iteratorSymbol) {
|
exports[Symbol.iterator] = exports.values;
|
||||||
exports[iteratorSymbol] = exports.values;
|
|
||||||
}
|
|
||||||
|
|
|
@ -588,22 +588,18 @@ module.exports = {
|
||||||
TestCase.assertEqual(list.reduceRight(function(n, p) {return n + p.age}, 0), 33);
|
TestCase.assertEqual(list.reduceRight(function(n, p) {return n + p.age}, 0), 33);
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
var iteratorSymbol = typeof Symbol != 'undefined' && Symbol.iterator;
|
|
||||||
var iteratorMethodNames = ['entries', 'keys', 'values'];
|
var iteratorMethodNames = ['entries', 'keys', 'values'];
|
||||||
|
|
||||||
if (iteratorSymbol) {
|
iteratorMethodNames.push(Symbol.iterator);
|
||||||
iteratorMethodNames.push(iteratorSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
iteratorMethodNames.forEach(function(methodName) {
|
iteratorMethodNames.forEach(function(methodName) {
|
||||||
var iterator = list[methodName]();
|
var iterator = list[methodName]();
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
if (iteratorSymbol) {
|
|
||||||
// This iterator should itself be iterable.
|
// This iterator should itself be iterable.
|
||||||
TestCase.assertEqual(iterator[iteratorSymbol](), iterator);
|
// TestCase.assertEqual(iterator[iteratorSymbol](), iterator);
|
||||||
}
|
TestCase.assertEqual(iterator[Symbol.iterator](), iterator);
|
||||||
|
|
||||||
while ((result = iterator.next()) && !result.done) {
|
while ((result = iterator.next()) && !result.done) {
|
||||||
var value = result.value;
|
var value = result.value;
|
||||||
|
|
Loading…
Reference in New Issue