michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* ES6 20121122 draft 15.14.4.4. */ michael@0: michael@0: function MapForEach(callbackfn, thisArg = undefined) { michael@0: /* Step 1-2. */ michael@0: var M = this; michael@0: if (!IsObject(M)) michael@0: ThrowError(JSMSG_BAD_TYPE, typeof M); michael@0: michael@0: /* Step 3-4. */ michael@0: try { michael@0: callFunction(std_Map_has, M); michael@0: } catch (e) { michael@0: ThrowError(JSMSG_BAD_TYPE, typeof M); michael@0: } michael@0: michael@0: /* Step 5. */ michael@0: if (!IsCallable(callbackfn)) michael@0: ThrowError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn)); michael@0: michael@0: /* Step 6-8. */ michael@0: var entries = callFunction(std_Map_iterator, M); michael@0: while (true) { michael@0: var result = callFunction(std_Map_iterator_next, entries); michael@0: if (result.done) michael@0: break; michael@0: var entry = result.value; michael@0: callFunction(callbackfn, thisArg, entry[1], entry[0], M); michael@0: } michael@0: }