mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
LibJS: Add JSON.stringify
This commit is contained in:
parent
b4577ffcf3
commit
39576b2238
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