• Formats a number into a string representation with optional currency prefix and comma separators.

    Parameters

    • number: string | number | bigint | boolean

      The number to format.

    • Optionaloptions: NumberFormatterOptions = ...

      Options for formatting.

    • OptionaldecimalPlaces: number = 0

      The number of decimal places to use. Defaults to 0.

    • Optionalprecision: number = 100

      The precision to use for the Decimal instance. Defaults to 100.

    Returns string

    The formatted number.

    numberFormatter(123456789); // "123,456,789"
    numberFormatter(123456789, { currencyPrefix: "$" }); // "$123,456,789"
    numberFormatter(123456789, { addCommaSeparators: false }); // "123456789"
    numberFormatter(123456789, { currencyPrefix: "$", addCommaSeparators: false }); // "$123456789"