NumberFormatConstructor.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/Intl/NumberFormat.h>
  8. #include <LibJS/Runtime/NativeFunction.h>
  9. namespace JS::Intl {
  10. class NumberFormatConstructor final : public NativeFunction {
  11. JS_OBJECT(NumberFormatConstructor, NativeFunction);
  12. public:
  13. virtual void initialize(Realm&) override;
  14. virtual ~NumberFormatConstructor() override = default;
  15. virtual ThrowCompletionOr<Value> call() override;
  16. virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
  17. private:
  18. explicit NumberFormatConstructor(Realm&);
  19. virtual bool has_constructor() const override { return true; }
  20. JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
  21. };
  22. ThrowCompletionOr<NumberFormat*> initialize_number_format(VM&, NumberFormat&, Value locales_value, Value options_value);
  23. ThrowCompletionOr<void> set_number_format_digit_options(VM&, NumberFormatBase& intl_object, Object const& options, int default_min_fraction_digits, int default_max_fraction_digits, NumberFormat::Notation notation);
  24. ThrowCompletionOr<void> set_number_format_unit_options(VM&, NumberFormat& intl_object, Object const& options);
  25. }