Files
palemoon27/js/src/builtin/Set.js
T
roytam1 27926d796f import changes from `dev' branch of rmottola/Arctic-Fox:
- fix assertion (528f0d0b2)
- fix assertion (8ca4607ca)
- fix broken assertions (8c64c1865)
- fix debug code (6e37f6aa7)
- remove broken assertion (090f9987d)
- fix assertion according to bug Bug 1328251 (b3835e0c5)
- fix debug code (f7a2841e6)
- Bug 1226241 - Use a #define instead of a magic number for self-hosted function name accesses. r=jandem (01e2ec474)
-  Bug 1235656 - Part 1: Set canonical name in self-hosted builtins. r=till (43cbd7cb9)
- Bug 912701 - When removing Unicode extension sequences from a locale, ignore similar syntax that might be found in a privateuse component. r=abargull (1524a8b48)
- remove broken assert (a93490758)
- remove broken assert (0ddc7e143)
- fix missing bracket (c4f524729)
- Bug 1179924 - Create a more modern JS object holder for cross-thread references to JS objects. r=smaug (0804d24cf)
2021-10-19 09:47:04 +08:00

42 lines
1.2 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* ES6 20121122 draft 15.16.4.6. */
function SetForEach(callbackfn, thisArg = undefined) {
/* Step 1-2. */
var S = this;
if (!IsObject(S))
ThrowTypeError(JSMSG_INCOMPATIBLE_PROTO, "Set", "forEach", typeof S);
/* Step 3-4. */
try {
callFunction(std_Set_has, S);
} catch (e) {
// has will throw on non-Set objects, throw our own error in that case.
ThrowTypeError(JSMSG_INCOMPATIBLE_PROTO, "Set", "forEach", typeof S);
}
/* Step 5-6. */
if (!IsCallable(callbackfn))
ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
/* Step 7-8. */
var values = callFunction(std_Set_iterator, S);
while (true) {
var result = callFunction(std_Set_iterator_next, values);
if (result.done)
break;
var value = result.value;
callFunction(callbackfn, thisArg, value, value, S);
}
}
// ES6 final draft 23.2.2.2.
function SetSpecies() {
// Step 1.
return this;
}
_SetCanonicalName(SetSpecies, "get [Symbol.species]");