|
@@ -5,6 +5,7 @@
|
|
|
*/
|
|
|
|
|
|
#include <AK/HashTable.h>
|
|
|
+#include <LibJS/Runtime/SetIterator.h>
|
|
|
#include <LibJS/Runtime/SetPrototype.h>
|
|
|
|
|
|
namespace JS {
|
|
@@ -23,11 +24,15 @@ void SetPrototype::initialize(GlobalObject& global_object)
|
|
|
define_native_function(vm.names.add, add, 1, attr);
|
|
|
define_native_function(vm.names.clear, clear, 0, attr);
|
|
|
define_native_function(vm.names.delete_, delete_, 1, attr);
|
|
|
+ define_native_function(vm.names.entries, entries, 0, attr);
|
|
|
define_native_function(vm.names.forEach, for_each, 1, attr);
|
|
|
define_native_function(vm.names.has, has, 1, attr);
|
|
|
+ define_native_function(vm.names.values, values, 0, attr);
|
|
|
|
|
|
define_native_property(vm.names.size, size_getter, {}, attr);
|
|
|
|
|
|
+ define_property(vm.names.keys, get(vm.names.values), attr);
|
|
|
+ define_property(vm.well_known_symbol_iterator(), get(vm.names.values), attr);
|
|
|
define_property(vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.Set), Attribute::Configurable);
|
|
|
}
|
|
|
|
|
@@ -64,6 +69,15 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::delete_)
|
|
|
return Value(set->values().remove(vm.argument(0)));
|
|
|
}
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(SetPrototype::entries)
|
|
|
+{
|
|
|
+ auto* set = typed_this(vm, global_object);
|
|
|
+ if (!set)
|
|
|
+ return {};
|
|
|
+
|
|
|
+ return SetIterator::create(global_object, *set, Object::PropertyKind::KeyAndValue);
|
|
|
+}
|
|
|
+
|
|
|
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::for_each)
|
|
|
{
|
|
|
auto* set = typed_this(vm, global_object);
|
|
@@ -91,6 +105,15 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::has)
|
|
|
return Value(values.find(vm.argument(0)) != values.end());
|
|
|
}
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(SetPrototype::values)
|
|
|
+{
|
|
|
+ auto* set = typed_this(vm, global_object);
|
|
|
+ if (!set)
|
|
|
+ return {};
|
|
|
+
|
|
|
+ return SetIterator::create(global_object, *set, Object::PropertyKind::Value);
|
|
|
+}
|
|
|
+
|
|
|
JS_DEFINE_NATIVE_GETTER(SetPrototype::size_getter)
|
|
|
{
|
|
|
auto* set = typed_this(vm, global_object);
|