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