summaryrefslogtreecommitdiff
path: root/deps/v8/src/collection.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/collection.js')
-rw-r--r--deps/v8/src/collection.js41
1 files changed, 11 insertions, 30 deletions
diff --git a/deps/v8/src/collection.js b/deps/v8/src/collection.js
index 94bda70357..c8cf639f97 100644
--- a/deps/v8/src/collection.js
+++ b/deps/v8/src/collection.js
@@ -20,26 +20,17 @@ function SetConstructor(iterable) {
throw MakeTypeError('constructor_not_function', ['Set']);
}
- var iter, adder;
+ %_SetInitialize(this);
if (!IS_NULL_OR_UNDEFINED(iterable)) {
- iter = GetIterator(ToObject(iterable));
- adder = this.add;
+ var adder = this.add;
if (!IS_SPEC_FUNCTION(adder)) {
throw MakeTypeError('property_not_function', ['add', this]);
}
- }
-
- %_SetInitialize(this);
-
- if (IS_UNDEFINED(iter)) return;
- var next, done;
- while (!(next = iter.next()).done) {
- if (!IS_SPEC_OBJECT(next)) {
- throw MakeTypeError('iterator_result_not_an_object', [next]);
+ for (var value of iterable) {
+ %_CallFunction(this, value, adder);
}
- %_CallFunction(this, next.value, adder);
}
}
@@ -160,30 +151,20 @@ function MapConstructor(iterable) {
throw MakeTypeError('constructor_not_function', ['Map']);
}
- var iter, adder;
+ %_MapInitialize(this);
if (!IS_NULL_OR_UNDEFINED(iterable)) {
- iter = GetIterator(ToObject(iterable));
- adder = this.set;
+ var adder = this.set;
if (!IS_SPEC_FUNCTION(adder)) {
throw MakeTypeError('property_not_function', ['set', this]);
}
- }
-
- %_MapInitialize(this);
- if (IS_UNDEFINED(iter)) return;
-
- var next, done, nextItem;
- while (!(next = iter.next()).done) {
- if (!IS_SPEC_OBJECT(next)) {
- throw MakeTypeError('iterator_result_not_an_object', [next]);
- }
- nextItem = next.value;
- if (!IS_SPEC_OBJECT(nextItem)) {
- throw MakeTypeError('iterator_value_not_an_object', [nextItem]);
+ for (var nextItem of iterable) {
+ if (!IS_SPEC_OBJECT(nextItem)) {
+ throw MakeTypeError('iterator_value_not_an_object', [nextItem]);
+ }
+ %_CallFunction(this, nextItem[0], nextItem[1], adder);
}
- %_CallFunction(this, nextItem[0], nextItem[1], adder);
}
}