diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-03-27 13:21:40 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-03-27 13:21:40 +0200 |
commit | e19749682050ff716fc9ff3bbc05ee3911570670 (patch) | |
tree | 4213a4e8efdaadea0409642702ec6c499f7b9ccc /js/src/builtin/Map.js | |
parent | 72721d1d032db2099593076bf96f274623af3c26 (diff) | |
parent | 70c8cf8db71880c1ab1f8fee4787a19316960dac (diff) | |
download | UXP-e19749682050ff716fc9ff3bbc05ee3911570670.tar UXP-e19749682050ff716fc9ff3bbc05ee3911570670.tar.gz UXP-e19749682050ff716fc9ff3bbc05ee3911570670.tar.lz UXP-e19749682050ff716fc9ff3bbc05ee3911570670.tar.xz UXP-e19749682050ff716fc9ff3bbc05ee3911570670.zip |
Merge remote-tracking branch 'janek/js_IteratorClose_1'
Diffstat (limited to 'js/src/builtin/Map.js')
-rw-r--r-- | js/src/builtin/Map.js | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/js/src/builtin/Map.js b/js/src/builtin/Map.js index 27a12bfff..580629a13 100644 --- a/js/src/builtin/Map.js +++ b/js/src/builtin/Map.js @@ -14,44 +14,14 @@ function MapConstructorInit(iterable) { if (!IsCallable(adder)) ThrowTypeError(JSMSG_NOT_FUNCTION, typeof adder); - // Step 6.c. - var iterFn = iterable[std_iterator]; - if (!IsCallable(iterFn)) - ThrowTypeError(JSMSG_NOT_ITERABLE, DecompileArg(0, iterable)); - - var iter = callContentFunction(iterFn, iterable); - if (!IsObject(iter)) - ThrowTypeError(JSMSG_NOT_NONNULL_OBJECT, typeof iter); - - // Step 7 (not applicable). - - // Step 8. - while (true) { - // Step 8.a. - var next = callContentFunction(iter.next, iter); - if (!IsObject(next)) - ThrowTypeError(JSMSG_NOT_NONNULL_OBJECT, typeof next); - - // Step 8.b. - if (next.done) - return; - - // Step 8.c. - var nextItem = next.value; - + // Steps 6.c-8. + for (var nextItem of allowContentIter(iterable)) { // Step 8.d. - if (!IsObject(nextItem)) { - IteratorCloseThrow(iter); + if (!IsObject(nextItem)) ThrowTypeError(JSMSG_INVALID_MAP_ITERABLE, "Map"); - } // Steps 8.e-j. - try { - callContentFunction(adder, map, nextItem[0], nextItem[1]); - } catch (e) { - IteratorCloseThrow(iter); - throw e; - } + callContentFunction(adder, map, nextItem[0], nextItem[1]); } } |