mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibJS: Convert to_u16() to ThrowCompletionOr
This commit is contained in:
parent
627b1205ce
commit
7bbb92dfe9
Notes:
sideshowbarker
2024-07-18 02:12:31 +09:00
Author: https://github.com/IdanHo
Commit: 7bbb92dfe9
Pull-request: https://github.com/SerenityOS/serenity/pull/10522
Reviewed-by: https://github.com/linusg ✅
5 changed files with 7 additions and 13 deletions
|
@ -624,9 +624,9 @@ ThrowCompletionOr<i16> Value::to_i16(GlobalObject& global_object) const
|
|||
}
|
||||
|
||||
// 7.1.9 ToUint16 ( argument ), https://tc39.es/ecma262/#sec-touint16
|
||||
u16 Value::to_u16(GlobalObject& global_object) const
|
||||
ThrowCompletionOr<u16> Value::to_u16(GlobalObject& global_object) const
|
||||
{
|
||||
double value = TRY_OR_DISCARD(to_number(global_object)).as_double();
|
||||
double value = TRY(to_number(global_object)).as_double();
|
||||
if (!isfinite(value) || value == 0)
|
||||
return 0;
|
||||
auto int_val = floor(fabs(value));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue