base-formatter
    Preparing search index...

    Class BaseFormatter

    The class from which to create a BaseFormatter instance for encoding to a string format from specified digits.

    Index

    Constructors

    • The constructor of the BaseFormatter class.

      Parameters

      • digits: string | string[]

        A string of symbols for representing the digits, the length of which determining the base number.

      • options: BaseFormatterOptions = {}

        Optional parameters, for adjusting conversion rules and the encoding output string formatting.

      Returns BaseFormatter

    Properties

    base: number

    The base number

    digits: string[]

    The digits to use.

    properties: BaseFormatterProperties

    The properties of the class, set by the options of the constructor

    Instance Methods

    • Decode an en encoded number according to the instance base and specified digits and properties.

      Parameters

      • encodedValue: string

        An encoded number as a string in the instance base.

      • Optionaloptions: BaseFormatterOptions

        The options to use if, for example, alternative characters were specified during encoding.

      Returns number

      The decoded number.

      DigitNotFound when the specified string contains unknown characters.

    • Encodes the specified number according to the instance base and specified digits and properties.

      Parameters

      • numberValue: string | number | Decimal

        The number to encode, as a number, string or Decimal type.

      • Optionaloptions: BaseFormatterOptions

        The options to use for formatting.

      Returns string

      the encoded number as a string.

    • Check if the specified value is a number according to the instance base and specified digits and properties.

      Parameters

      • value: string

        A string to check.

      Returns boolean

      Whether the specified string is a number.

    Static Methods