LibJS: Prefer "define_property" over "put"

This commit is contained in:
Matthew Olsson 2020-07-11 07:58:56 -07:00 committed by Andreas Kling
parent c485c86015
commit 531fdb2e82
Notes: sideshowbarker 2024-07-19 04:56:33 +09:00
3 changed files with 5 additions and 5 deletions

View file

@ -182,7 +182,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map)
for_each_item(interpreter, global_object, "map", [&](auto index, auto, auto callback_result) {
if (interpreter.exception())
return IterationDecision::Break;
new_array->put(index, callback_result);
new_array->define_property(index, callback_result);
return IterationDecision::Continue;
});
return Value(new_array);

View file

@ -112,8 +112,8 @@ void iterator_close(Object& iterator)
Value create_iterator_result_object(Interpreter& interpreter, GlobalObject& global_object, Value value, bool done)
{
auto* object = Object::create_empty(interpreter, global_object);
object->put("value", value);
object->put("done", Value(done));
object->define_property("value", value);
object->define_property("done", Value(done));
return object;
}

View file

@ -433,7 +433,7 @@ Object* JSONObject::parse_json_object(Interpreter& interpreter, GlobalObject& gl
{
auto* object = Object::create_empty(interpreter, global_object);
json_object.for_each_member([&](auto& key, auto& value) {
object->put(key, parse_json_value(interpreter, global_object, value));
object->define_property(key, parse_json_value(interpreter, global_object, value));
});
return object;
}
@ -443,7 +443,7 @@ Array* JSONObject::parse_json_array(Interpreter& interpreter, GlobalObject& glob
auto* array = Array::create(global_object);
size_t index = 0;
json_array.for_each([&](auto& value) {
array->put(index++, parse_json_value(interpreter, global_object, value));
array->define_property(index++, parse_json_value(interpreter, global_object, value));
});
return array;
}