1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:04:59 +00:00

LibJS: Update spec numbers for the Array Grouping proposal

This proposal has been merged into the main ECMA-262 spec. See:
3a9c9dc
This commit is contained in:
Timothy Flynn 2023-12-26 08:55:15 -05:00 committed by Tim Flynn
parent 4c17620712
commit edbc2a1031
3 changed files with 18 additions and 19 deletions

View file

@ -180,7 +180,7 @@ Vector<T> merge_lists(Vector<T> const& a, Vector<T> const& b)
return merged;
}
// 4.2 AddValueToKeyedGroup ( groups, key, value ), https://tc39.es/proposal-array-grouping/#sec-add-value-to-keyed-group
// 7.3.35 AddValueToKeyedGroup ( groups, key, value ), https://tc39.es/ecma262/#sec-add-value-to-keyed-group
template<typename GroupsType, typename KeyType>
void add_value_to_keyed_group(VM& vm, GroupsType& groups, KeyType key, Value value)
{
@ -210,7 +210,7 @@ void add_value_to_keyed_group(VM& vm, GroupsType& groups, KeyType key, Value val
// 4. Return unused.
}
// 4.1 GroupBy ( items, callbackfn, keyCoercion ), https://tc39.es/proposal-array-grouping/#sec-group-by
// 7.3.36 GroupBy ( items, callbackfn, keyCoercion ), https://tc39.es/ecma262/#sec-groupby
template<typename GroupsType, typename KeyType>
ThrowCompletionOr<GroupsType> group_by(VM& vm, Value items, Value callback_function)
{
@ -224,8 +224,7 @@ ThrowCompletionOr<GroupsType> group_by(VM& vm, Value items, Value callback_funct
// 3. Let groups be a new empty List.
GroupsType groups;
// 4. Let iteratorRecord be ? GetIterator(items).
// FIXME: The Array Grouping proposal is out of date - the `kind` parameter is now required.
// 4. Let iteratorRecord be ? GetIterator(items, sync).
auto iterator_record = TRY(get_iterator(vm, items, IteratorHint::Sync));
// 5. Let k be 0.

View file

@ -26,7 +26,7 @@ void MapConstructor::initialize(Realm& realm)
auto& vm = this->vm();
Base::initialize(realm);
// 24.1.2.1 Map.prototype, https://tc39.es/ecma262/#sec-map.prototype
// 24.1.2.2 Map.prototype, https://tc39.es/ecma262/#sec-map.prototype
define_direct_property(vm.names.prototype, realm.intrinsics().map_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
@ -72,7 +72,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> MapConstructor::construct(FunctionObject
return map;
}
// 3.1 Map.groupBy ( items, callbackfn ), https://tc39.es/proposal-array-grouping/#sec-map.groupby
// 24.1.2.1 Map.groupBy ( items, callbackfn ), https://tc39.es/ecma262/#sec-map.groupby
JS_DEFINE_NATIVE_FUNCTION(MapConstructor::group_by)
{
auto& realm = *vm.current_realm();
@ -113,7 +113,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapConstructor::group_by)
return map;
}
// 24.1.2.2 get Map [ @@species ], https://tc39.es/ecma262/#sec-get-map-@@species
// 24.1.2.3 get Map [ @@species ], https://tc39.es/ecma262/#sec-get-map-@@species
JS_DEFINE_NATIVE_FUNCTION(MapConstructor::symbol_species_getter)
{
return vm.this_value();

View file

@ -29,7 +29,7 @@ void ObjectConstructor::initialize(Realm& realm)
auto& vm = this->vm();
Base::initialize(realm);
// 20.1.2.19 Object.prototype, https://tc39.es/ecma262/#sec-object.prototype
// 20.1.2.21 Object.prototype, https://tc39.es/ecma262/#sec-object.prototype
define_direct_property(vm.names.prototype, realm.intrinsics().object_prototype(), 0);
u8 attr = Attribute::Writable | Attribute::Configurable;
@ -373,7 +373,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_prototype_of)
return TRY(object->internal_get_prototype_of());
}
// 2.1 Object.groupBy ( items, callbackfn ), https://tc39.es/proposal-array-grouping/#sec-object.groupby
// 20.1.2.13 Object.groupBy ( items, callbackfn ), https://tc39.es/ecma262/#sec-object.groupby
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::group_by)
{
auto& realm = *vm.current_realm();
@ -400,7 +400,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::group_by)
return object;
}
// 20.1.2.13 Object.hasOwn ( O, P ), https://tc39.es/ecma262/#sec-object.hasown
// 20.1.2.14 Object.hasOwn ( O, P ), https://tc39.es/ecma262/#sec-object.hasown
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::has_own)
{
// 1. Let obj be ? ToObject(O).
@ -413,14 +413,14 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::has_own)
return Value(TRY(object->has_own_property(key)));
}
// 20.1.2.14 Object.is ( value1, value2 ), https://tc39.es/ecma262/#sec-object.is
// 20.1.2.15 Object.is ( value1, value2 ), https://tc39.es/ecma262/#sec-object.is
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is)
{
// 1. Return SameValue(value1, value2).
return Value(same_value(vm.argument(0), vm.argument(1)));
}
// 20.1.2.15 Object.isExtensible ( O ), https://tc39.es/ecma262/#sec-object.isextensible
// 20.1.2.16 Object.isExtensible ( O ), https://tc39.es/ecma262/#sec-object.isextensible
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is_extensible)
{
auto argument = vm.argument(0);
@ -433,7 +433,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is_extensible)
return Value(TRY(argument.as_object().is_extensible()));
}
// 20.1.2.16 Object.isFrozen ( O ), https://tc39.es/ecma262/#sec-object.isfrozen
// 20.1.2.17 Object.isFrozen ( O ), https://tc39.es/ecma262/#sec-object.isfrozen
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is_frozen)
{
auto argument = vm.argument(0);
@ -446,7 +446,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is_frozen)
return Value(TRY(argument.as_object().test_integrity_level(Object::IntegrityLevel::Frozen)));
}
// 20.1.2.17 Object.isSealed ( O ), https://tc39.es/ecma262/#sec-object.issealed
// 20.1.2.18 Object.isSealed ( O ), https://tc39.es/ecma262/#sec-object.issealed
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is_sealed)
{
auto argument = vm.argument(0);
@ -459,7 +459,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::is_sealed)
return Value(TRY(argument.as_object().test_integrity_level(Object::IntegrityLevel::Sealed)));
}
// 20.1.2.18 Object.keys ( O ), https://tc39.es/ecma262/#sec-object.keys
// 20.1.2.19 Object.keys ( O ), https://tc39.es/ecma262/#sec-object.keys
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::keys)
{
auto& realm = *vm.current_realm();
@ -474,7 +474,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::keys)
return Array::create_from(realm, name_list);
}
// 20.1.2.19 Object.preventExtensions ( O ), https://tc39.es/ecma262/#sec-object.preventextensions
// 20.1.2.20 Object.preventExtensions ( O ), https://tc39.es/ecma262/#sec-object.preventextensions
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::prevent_extensions)
{
auto argument = vm.argument(0);
@ -496,7 +496,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::prevent_extensions)
return argument;
}
// 20.1.2.21 Object.seal ( O ), https://tc39.es/ecma262/#sec-object.seal
// 20.1.2.22 Object.seal ( O ), https://tc39.es/ecma262/#sec-object.seal
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::seal)
{
auto argument = vm.argument(0);
@ -516,7 +516,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::seal)
return argument;
}
// 20.1.2.22 Object.setPrototypeOf ( O, proto ), https://tc39.es/ecma262/#sec-object.setprototypeof
// 20.1.2.23 Object.setPrototypeOf ( O, proto ), https://tc39.es/ecma262/#sec-object.setprototypeof
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::set_prototype_of)
{
auto proto = vm.argument(1);
@ -545,7 +545,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::set_prototype_of)
return object;
}
// 20.1.2.23 Object.values ( O ), https://tc39.es/ecma262/#sec-object.values
// 20.1.2.24 Object.values ( O ), https://tc39.es/ecma262/#sec-object.values
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::values)
{
auto& realm = *vm.current_realm();