mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
LibJS: Add JSON.stringify
This commit is contained in:
parent
b4577ffcf3
commit
39576b2238
Notes:
sideshowbarker
2024-07-19 05:40:49 +09:00
Author: https://github.com/mattco98
Commit: 39576b2238
Pull-request: https://github.com/SerenityOS/serenity/pull/2545
Reviewed-by: https://github.com/Dexesttp
Reviewed-by: https://github.com/awesomekling
19 changed files with 678 additions and 10 deletions
|
@ -81,6 +81,12 @@ bool Value::is_array() const
|
|||
return is_object() && as_object().is_array();
|
||||
}
|
||||
|
||||
Array& Value::as_array()
|
||||
{
|
||||
ASSERT(is_array());
|
||||
return static_cast<Array&>(*m_value.as_object);
|
||||
}
|
||||
|
||||
bool Value::is_function() const
|
||||
{
|
||||
return is_object() && as_object().is_function();
|
||||
|
@ -940,4 +946,13 @@ TriState abstract_relation(Interpreter& interpreter, bool left_first, Value lhs,
|
|||
return TriState::False;
|
||||
}
|
||||
|
||||
size_t length_of_array_like(Interpreter& interpreter, Value value)
|
||||
{
|
||||
ASSERT(value.is_object());
|
||||
auto result = value.as_object().get("length");
|
||||
if (interpreter.exception())
|
||||
return 0;
|
||||
return result.to_size_t(interpreter);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue