LibJS: Make more use of Value::is and Value::as_if

This commit is contained in:
Shannon Booth
2026-02-28 12:44:47 +01:00
committed by Tim Flynn
parent 4c8723e2d8
commit 502ae99102
Notes: github-actions[bot] 2026-02-28 15:26:17 +00:00
15 changed files with 67 additions and 96 deletions

View File

@@ -80,14 +80,14 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferConstructor::is_view)
auto arg = vm.argument(0);
// 1. If arg is not an Object, return false.
if (!arg.is_object())
auto object = arg.as_if<Object>();
if (!object)
return false;
auto const& object = arg.as_object();
// 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
if (object.is_typed_array())
if (object->is_typed_array())
return true;
if (is<DataView>(object))
if (is<DataView>(*object))
return true;
// 3. Return false.