Variable formats

formats: {
    alphabet: {
        config: {
            alphabet: string;
        };
        format(ex: DecimalSource, acc?: number, max?: number, type?: FormatType, start?: DecimalSource, startDouble?: boolean, abbStart?: number): string;
        getAbbreviation(ex: DecimalSource, start?: DecimalSource, startDouble?: boolean, abbStart?: number): string;
    };
    elemental: {
        config: {
            element_lists: string[][];
        };
        abbreviationLength(group: number): number;
        beyondOg(x: number): string;
        format(value: Decimal, acc?: number): string;
        formatElementalPart(abbreviation: string, n: Decimal): string;
        getAbbreviation(group: number, progress: number): string;
        getAbbreviationAndValue(x: Decimal): [string, Decimal];
        getOffset(group: number): number;
    };
    eng: {
        format(ex: DecimalSource, acc?: number): string;
    };
    ev: ((num: DecimalSource, c2?: boolean) => string);
    expMult: ((a: DecimalSource, b: DecimalSource, base?: number) => Decimal);
    format: ((ex: DecimalSource, acc?: number, max?: number, type?: FormatType) => string);
    formatGain: ((amt: DecimalSource, gain: DecimalSource, type?: FormatType, acc?: number, max?: number) => string);
    formatMult: ((ex: DecimalSource, acc?: number) => string);
    formatPercent: ((ex: DecimalSource) => string);
    formatReduction: ((ex: DecimalSource) => string);
    formatST: ((ex: DecimalSource, acc?: number, max?: number, type?: FormatType) => string);
    formatTime: ((ex: DecimalSource, acc?: number, type?: string) => string);
    formatTimeLong: ((ex: DecimalSource, ms?: boolean, acc?: number, max?: number, type?: FormatType) => string);
    inf: {
        format(ex: DecimalSource, acc?: number, max?: number): string;
    };
    layer: {
        layers: string[];
        format(ex: DecimalSource, acc?: number, max?: number): string;
    };
    metric: ((num: DecimalSource, type?:
        | 0
        | 1
        | 2
        | 3) => string);
    mixed_sc: {
        format(ex: DecimalSource, acc?: number, max?: number): string;
    };
    old_sc: {
        format(ex: DecimalSource, acc: number): string;
    };
    omega: {
        config: {
            greek: string;
            infinity: string;
        };
        format(value: DecimalSource): string;
    };
    omega_short: {
        config: {
            greek: string;
            infinity: string;
        };
        format(value: DecimalSource): string;
    };
    standard: {
        tier1(x: number): string;
        tier2(x: number): string;
    };
    toSubscript: ((value: number) => string);
    toSuperscript: ((value: number) => string);
}

Type declaration

  • alphabet: {
        config: {
            alphabet: string;
        };
        format(ex: DecimalSource, acc?: number, max?: number, type?: FormatType, start?: DecimalSource, startDouble?: boolean, abbStart?: number): string;
        getAbbreviation(ex: DecimalSource, start?: DecimalSource, startDouble?: boolean, abbStart?: number): string;
    }

    Alphabet format

    • config: {
          alphabet: string;
      }
      • alphabet: string
    • format:function
      • Format the value into alphabet format (a, b, c, ..., z, aa, ab, ac, ... aaa, aab, ... aaaa, ... aaaaaaaaaaaaaaa, ... aaaaaaaaaaaaaaa(2), aaaaaaaaaaaaaaa(3), ...) Basically base 26 for the exponential part / 3 Work in progress

        Parameters

        • ex: DecimalSource

          The value to format

        • acc: number = 2

          The accuracy

        • max: number = 9

          The maximum value before switching to an abbreviation

        • type: FormatType = "mixed_sc"

          The type of format to use

        • start: DecimalSource = ...

          The starting value. Defaults to 1e15, or 1 quadrillion.

        • startDouble: boolean = false

          Whether to start at aa instead of a. Defaults to false.

        • OptionalabbStart: number

          The starting value for abbreviations. Defaults to 9.

        Returns string

        • The formatted value
    • getAbbreviation:function
      • Get the abbreviation for a number

        Parameters

        • ex: DecimalSource

          The value to get the abbreviation for

        • start: DecimalSource = ...

          The starting value

        • startDouble: boolean = false

          Whether to start at aa instead of a

        • abbStart: number = 9

          The starting value for abbreviations

        Returns string

        • The abbreviation
  • elemental: {
        config: {
            element_lists: string[][];
        };
        abbreviationLength(group: number): number;
        beyondOg(x: number): string;
        format(value: Decimal, acc?: number): string;
        formatElementalPart(abbreviation: string, n: Decimal): string;
        getAbbreviation(group: number, progress: number): string;
        getAbbreviationAndValue(x: Decimal): [string, Decimal];
        getOffset(group: number): number;
    }
    • config: {
          element_lists: string[][];
      }
      • element_lists: string[][]

        The list of elements

    • abbreviationLength:function
      • Parameters

        • group: number

        Returns number

    • beyondOg:function
      • Parameters

        • x: number

        Returns string

    • format:function
    • formatElementalPart:function
      • Parameters

        Returns string

    • getAbbreviation:function
      • Parameters

        • group: number
        • progress: number

        Returns string

    • getAbbreviationAndValue:function
    • getOffset:function
      • Parameters

        • group: number

        Returns number

  • eng: {
        format(ex: DecimalSource, acc?: number): string;
    }

    Engineering format

    • format:function
      • Format the value into engineering format

        Parameters

        • ex: DecimalSource

          The value to format

        • acc: number = 2

          The accuracy

        Returns string

        • The formatted value
        console.log(FORMATS.eng.format(1e20, 2)); // 100.00e18
        
  • ev: ((num: DecimalSource, c2?: boolean) => string)
      • (num, c2?): string
      • Format the value into eV (includes metric prefixes)

        Parameters

        • num: DecimalSource

          The value to format

        • c2: boolean = false

          Whether to include /c^2

        Returns string

        The formatted value

        Use metric instead

  • expMult: ((a: DecimalSource, b: DecimalSource, base?: number) => Decimal)
      • (a, b, base?): Decimal
      • Exponential multiplier

        Parameters

        Returns Decimal

        • The value after being exponentiated
  • format: ((ex: DecimalSource, acc?: number, max?: number, type?: FormatType) => string)
      • (ex, acc?, max?, type?): string
      • Format the value into a specific format type

        Parameters

        • ex: DecimalSource

          The value to format

        • acc: number = 2

          The desired accuracy (number of significant figures), defaults to 2.

        • max: number = 9

          The maximum number of decimal places to display, defaults to 9.

        • type: FormatType = "mixed_sc"

          The type of format to use (default "mixed_sc")

        Returns string

        • The formatted value
  • formatGain: ((amt: DecimalSource, gain: DecimalSource, type?: FormatType, acc?: number, max?: number) => string)
      • (amt, gain, type?, acc?, max?): string
      • Format the gain

        Parameters

        Returns string

        • The formatted gain
        console.log(formatGain(1e20, 1e10)); // (+1.00e10/sec)
        console.log(formatGain(1e200, 1e210)); // (+10.00 OoMs/sec)
  • formatMult: ((ex: DecimalSource, acc?: number) => string)
      • (ex, acc?): string
      • Format the multiplier

        Parameters

        • ex: DecimalSource

          The value to format

        • acc: number = 2

          The accuracy

        Returns string

        • The formatted multiplier
  • formatPercent: ((ex: DecimalSource) => string)
      • (ex): string
      • Format the percent

        Parameters

        Returns string

        • The formatted percent
  • formatReduction: ((ex: DecimalSource) => string)
      • (ex): string
      • Format the reduction

        Parameters

        Returns string

        • The formatted reduction
  • formatST: ((ex: DecimalSource, acc?: number, max?: number, type?: FormatType) => string)
      • (ex, acc?, max?, type?): string
      • Format the value into standard (letter abbv) format

        Parameters

        Returns string

        Use format instead (with the type "st")

  • formatTime: ((ex: DecimalSource, acc?: number, type?: string) => string)
      • (ex, acc?, type?): string
      • Format the time

        Parameters

        • ex: DecimalSource

          The value to format (in seconds)

        • acc: number = 2

          The accuracy

        • type: string = "s"

          The type

        Returns string

        • The formatted time
  • formatTimeLong: ((ex: DecimalSource, ms?: boolean, acc?: number, max?: number, type?: FormatType) => string)
      • (ex, ms?, acc?, max?, type?): string
      • Format the time long

        Parameters

        • ex: DecimalSource

          The value to format (in seconds)

        • ms: boolean = false

          Whether to include milliseconds

        • acc: number = 0

          The accuracy

        • max: number = 9

          The maximum value

        • type: FormatType = "mixed_sc"

          The type

        Returns string

        • The formatted time
  • inf: {
        format(ex: DecimalSource, acc?: number, max?: number): string;
    }

    Infinity format

    • format:function
  • layer: {
        layers: string[];
        format(ex: DecimalSource, acc?: number, max?: number): string;
    }

    Layer format

    • layers: string[]
    • format:function
  • metric: ((num: DecimalSource, type?:
        | 0
        | 1
        | 2
        | 3) => string)
      • (num, type?): string
      • Converts a number to a metric representation based on the specified type.

        Parameters

        • num: DecimalSource

          The number to convert.

        • type:
              | 0
              | 1
              | 2
              | 3 = 0

          The type of metric representation to return.

          • 0: Returns the number with the metric abbreviation (e.g., "1.23 K").
          • 1: Returns only the metric abbreviation (e.g., "K").
          • 2: Returns the number divided by the metric value (e.g., "1.23").
          • 3: Returns the alternative name of the metric abbreviation (e.g., "Kilo").

        Returns string

        The metric representation of the number. If the number is greater than the highest metric value, the function returns the highest metric abbreviation.

        metric(1234, 0); // Returns "1.23 K"
        metric(1234, 1); // Returns "K"
        metric(1234, 2); // Returns "1.23"
        metric(1234, 3); // Returns "Kilo"
  • mixed_sc: {
        format(ex: DecimalSource, acc?: number, max?: number): string;
    }

    Mixed scientific format

    • format:function
      • Format the value into mixed scientific format (standard or scientific depending on the value)

        Parameters

        • ex: DecimalSource

          The value to format

        • Optionalacc: number

          The accuracy

        • max: number = 9

          The maximum value

        Returns string

        • The formatted value
        console.log(FORMATS.mixed_sc.format(1e20, 2, 9)); // 100.00 Qt
        console.log(FORMATS.mixed_sc.format(1e400, 2, 303)); // 1.00e400
  • old_sc: {
        format(ex: DecimalSource, acc: number): string;
    }

    Old scientific format

    • format:function
      • Format the value into old scientific format

        Parameters

        Returns string

        • The formatted value
  • omega: {
        config: {
            greek: string;
            infinity: string;
        };
        format(value: DecimalSource): string;
    }

    Omega format

    • config: {
          greek: string;
          infinity: string;
      }
      • greek: string
      • infinity: string
    • format:function
      • Format the value into omega format

        Parameters

        Returns string

        • The formatted value
  • omega_short: {
        config: {
            greek: string;
            infinity: string;
        };
        format(value: DecimalSource): string;
    }

    Short omega format

    • config: {
          greek: string;
          infinity: string;
      }
      • greek: string
      • infinity: string
    • format:function
      • Format the value into short omega format

        Parameters

        Returns string

        • The formatted value
  • standard: {
        tier1(x: number): string;
        tier2(x: number): string;
    }

    Standard (letter abbv) format

    • tier1:function
      • Gets the letter abbreviation for a number (e.g. 1 -> K) (0-1e3000)

        Parameters

        • x: number

          The number to get the letter abbreviation for

        Returns string

        • The letter abbreviation
    • tier2:function
      • Gets the tier 2 letter abbreviation for a number (e.g. 1 -> Mi) (1e3000+)

        Parameters

        • x: number

          The number to get the letter abbreviation for

        Returns string

        • The letter abbreviation
  • toSubscript: ((value: number) => string)
      • (value): string
      • Convert a number to a subscript

        Parameters

        • value: number

          The value to convert

        Returns string

        • The value in subscript
  • toSuperscript: ((value: number) => string)
      • (value): string
      • Convert a number to a superscript

        Parameters

        • value: number

          The value to convert

        Returns string

        • The value in superscript