Cosmo (JavaScript) — API reference
    Preparing search index...

    Interface NumberOptions

    Number-formatting controls for Cosmo.number, Cosmo.percentage and Cosmo.money. Field names match Intl.NumberFormat's options.

    Most fields map onto an ICU setting the PHP and Python ports expose too, so the contract is identical across all three ports. The exceptions are flagged inline as JS port only: these have no equivalent in the legacy ICU NumberFormatter (PHP) / DecimalFormat (Python) APIs those ports use, so they take effect in the JS port and are silently ignored by the others.

    interface NumberOptions {
        compactDisplay?: "short" | "long";
        maximumFractionDigits?: number;
        maximumSignificantDigits?: number;
        minimumFractionDigits?: number;
        minimumIntegerDigits?: number;
        minimumSignificantDigits?: number;
        notation?: "standard" | "scientific" | "engineering" | "compact";
        roundingIncrement?:
            | 1
            | 2
            | 5
            | 10
            | 20
            | 25
            | 50
            | 100
            | 200
            | 250
            | 500
            | 1000
            | 2000
            | 2500
            | 5000;
        roundingMode?: | "ceil"
        | "floor"
        | "expand"
        | "trunc"
        | "halfExpand"
        | "halfTrunc"
        | "halfEven";
        roundingPriority?: "auto"
        | "morePrecision"
        | "lessPrecision";
        signDisplay?: "auto" | "always" | "exceptZero" | "negative" | "never";
        trailingZeroDisplay?: "auto" | "stripIfInteger";
        useGrouping?: boolean | "min2" | "auto" | "always";
    }
    Index

    Properties

    compactDisplay?: "short" | "long"

    Only meaningful with notation: "compact". JS port only — ignored by the PHP and Python ports.

    maximumFractionDigits?: number
    maximumSignificantDigits?: number

    Maximum significant digits.

    minimumFractionDigits?: number
    minimumIntegerDigits?: number

    Minimum integer digits; zero-pads the whole part (5"005" at 3).

    minimumSignificantDigits?: number

    Minimum significant digits (ICU treats significant- and fraction-digit limits as mutually exclusive).

    notation?: "standard" | "scientific" | "engineering" | "compact"

    JS port only — ignored by PHP/Python; for those ports use the dedicated compact() / scientific() methods instead.

    roundingIncrement?:
        | 1
        | 2
        | 5
        | 10
        | 20
        | 25
        | 50
        | 100
        | 200
        | 250
        | 500
        | 1000
        | 2000
        | 2500
        | 5000
    roundingMode?:
        | "ceil"
        | "floor"
        | "expand"
        | "trunc"
        | "halfExpand"
        | "halfTrunc"
        | "halfEven"

    ICU-portable rounding modes (these have a direct ICU equivalent in every port).

    roundingPriority?: "auto" | "morePrecision" | "lessPrecision"

    JS port only — ignored by the PHP and Python ports.

    signDisplay?: "auto" | "always" | "exceptZero" | "negative" | "never"

    JS port only — ignored by the PHP and Python ports (legacy ICU formatters have no sign-display attribute).

    trailingZeroDisplay?: "auto" | "stripIfInteger"

    JS port only — ignored by the PHP and Python ports.

    useGrouping?: boolean | "min2" | "auto" | "always"

    JS accepts the full union; the PHP and Python ports coerce any truthy value to "on".