mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibJS: Support the radix argument in BigInt.prototype.toString
This commit is contained in:
parent
005d75656e
commit
3cfe1a8914
Notes:
sideshowbarker
2024-07-18 11:20:42 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/3cfe1a89145 Pull-request: https://github.com/SerenityOS/serenity/pull/8314
@ -52,8 +52,17 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string)
|
||||
auto bigint_value = this_bigint_value(global_object, vm.this_value(global_object));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
// FIXME: Support radix argument
|
||||
return js_string(vm, bigint_value.as_bigint().big_integer().to_base(10));
|
||||
double radix = 10;
|
||||
if (!vm.argument(0).is_undefined()) {
|
||||
radix = vm.argument(0).to_integer_or_infinity(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (radix < 2 || radix > 36) {
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::InvalidRadix);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
return js_string(vm, bigint_value.as_bigint().big_integer().to_base(radix));
|
||||
}
|
||||
|
||||
// 21.2.3.2 BigInt.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-bigint.prototype.tolocalestring
|
||||
|
Loading…
Reference in New Issue
Block a user