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.16.4.6. */ michael@0: michael@0: function SetForEach(callbackfn, thisArg = undefined) { michael@0: /* Step 1-2. */ michael@0: var S = this; michael@0: if (!IsObject(S)) michael@0: ThrowError(JSMSG_BAD_TYPE, typeof S); michael@0: michael@0: /* Step 3-4. */ michael@0: try { michael@0: callFunction(std_Set_has, S); michael@0: } catch (e) { michael@0: ThrowError(JSMSG_BAD_TYPE, typeof S); michael@0: } michael@0: michael@0: /* Step 5-6. */ michael@0: if (!IsCallable(callbackfn)) michael@0: ThrowError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn)); michael@0: michael@0: /* Step 7-8. */ michael@0: var values = callFunction(std_Set_iterator, S); michael@0: while (true) { michael@0: var result = callFunction(std_Set_iterator_next, values); michael@0: if (result.done) michael@0: break; michael@0: var value = result.value; michael@0: callFunction(callbackfn, thisArg, value, value, S); michael@0: } michael@0: }