|
@@ -10,6 +10,7 @@
|
|
|
#include <LibJS/Runtime/FunctionObject.h>
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
#include <LibJS/Runtime/Iterator.h>
|
|
|
+#include <LibJS/Runtime/IteratorConstructor.h>
|
|
|
#include <LibJS/Runtime/IteratorHelper.h>
|
|
|
#include <LibJS/Runtime/IteratorPrototype.h>
|
|
|
#include <LibJS/Runtime/ValueInlines.h>
|
|
@@ -43,6 +44,9 @@ void IteratorPrototype::initialize(Realm& realm)
|
|
|
define_native_function(realm, vm.names.every, every, 1, attr);
|
|
|
define_native_function(realm, vm.names.find, find, 1, attr);
|
|
|
|
|
|
+ // 3.1.3.1 Iterator.prototype.constructor, https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.constructor
|
|
|
+ define_native_accessor(realm, vm.names.constructor, constructor_getter, constructor_setter, Attribute::Configurable);
|
|
|
+
|
|
|
// 3.1.3.13 Iterator.prototype [ @@toStringTag ], https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype-@@tostringtag
|
|
|
define_native_accessor(realm, vm.well_known_symbol_to_string_tag(), to_string_tag_getter, to_string_tag_setter, Attribute::Configurable);
|
|
|
}
|
|
@@ -54,6 +58,27 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::symbol_iterator)
|
|
|
return vm.this_value();
|
|
|
}
|
|
|
|
|
|
+// 3.1.3.1.1 get Iterator.prototype.constructor, https://tc39.es/proposal-iterator-helpers/#sec-get-iteratorprototype-constructor
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::constructor_getter)
|
|
|
+{
|
|
|
+ auto& realm = *vm.current_realm();
|
|
|
+
|
|
|
+ // 1. Return %Iterator%.
|
|
|
+ return realm.intrinsics().iterator_constructor();
|
|
|
+}
|
|
|
+
|
|
|
+// 3.1.3.1.2 set Iterator.prototype.constructor, https://tc39.es/proposal-iterator-helpers/#sec-set-iteratorprototype-constructor
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::constructor_setter)
|
|
|
+{
|
|
|
+ auto& realm = *vm.current_realm();
|
|
|
+
|
|
|
+ // 1. Perform ? SetterThatIgnoresPrototypeProperties(this value, %Iterator.prototype%, "constructor", v).
|
|
|
+ TRY(setter_that_ignores_prototype_properties(vm, vm.this_value(), realm.intrinsics().iterator_prototype(), vm.names.constructor, vm.argument(0)));
|
|
|
+
|
|
|
+ // 2. Return undefined.
|
|
|
+ return js_undefined();
|
|
|
+}
|
|
|
+
|
|
|
// 3.1.3.2 Iterator.prototype.map ( mapper ), https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.map
|
|
|
JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::map)
|
|
|
{
|