mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
LibJS: Publicly expose double_to_string and rename it number_to_string
Rename it to match the name used by the spec. Add an override mode to skip formatting numbers with an exponential sign (e.g. 1e23). This mode is needed by Number and Intl.NumberFormat, who don't call out a specific number-to-string method to use (they just say to make "the String consisting of the digits of n").
This commit is contained in:
parent
efe82e5c91
commit
9620a092de
2 changed files with 13 additions and 4 deletions
|
@ -564,6 +564,11 @@ ThrowCompletionOr<TriState> is_less_than(VM&, Value lhs, Value rhs, bool left_fi
|
|||
|
||||
double to_integer_or_infinity(double);
|
||||
|
||||
enum class NumberToStringMode {
|
||||
WithExponent,
|
||||
WithoutExponent,
|
||||
};
|
||||
String number_to_string(double, NumberToStringMode = NumberToStringMode::WithExponent);
|
||||
Optional<Value> string_to_number(StringView);
|
||||
|
||||
inline bool Value::operator==(Value const& value) const { return same_value(*this, value); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue