API Docs for:
Show:

AnyBaseConverter Class

AnyBaseConverter is an object that will convert numbers to and from a positional notation with a custom alphabet and base.

Item Index

Methods

Methods

from

(
  • any
)
Number

Converts a string from a custom base and returns a number.

Parameters:

Returns:

Number: value

to

(
  • value
)
String

Converts a number to a custom base and returns a string.

Parameters:

Returns:

String: any

Attributes

alphabet

String

The string of characters to use as single-digit numbers. The length of this string determines the base of the result. Each character should be unique within the string or else it will be impossible to correctly convert a string back into a number. Currently, non-BMP characters are not supported.

Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~'

Fires event alphabetChange

Fires when the value for the configuration attribute alphabet is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

lookup

Object protected

Used as a reverse lookup for a character index in alphabet.

Fires event lookupChange

Fires when the value for the configuration attribute lookup is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

minusSign

String

A single character string to prepend to negative values. This character should not be in the alphabet. Currently, non-BMP characters are not supported.

Default: '-'

Fires event minusSignChange

Fires when the value for the configuration attribute minusSign is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

radixPoint

String

A single character string to insert between the integer and fractional parts of the number. This character should not be in the alphabet. Currently, non-BMP characters are not supported.

Default: '.'

Fires event radixPointChange

Fires when the value for the configuration attribute radixPoint is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.