Options
All
  • Public
  • Public/Protected
  • All
Menu

The global class which keeps track of all unit mappings and global options.

This class is also responsible for creating dynamic classes and groups based on approximation when a desired unit is not defined by the developer.

Hierarchy

  • Core

Index

Properties

Static classMap

classMap: ClassMap

The map of defined classes by their name.

Static classes

classes: Class[] = []

An array of the defined classes.

Static dynamicGroups

dynamicGroups: GroupList = []

A list of dynamically created groups based on units specified by a user which are not defined by the developer.

Static dynamicMatchLength

dynamicMatchLength: number = 3

Dynamic groups are mapped together (by default) by looking at the first few characters.

see

Core.getDynamicMatch

Static dynamicMatches

dynamicMatches: GroupMap

A map of the dynamically created groups by a key determined by Core.getDynamicMatch.

Static globalOutput

globalOutput: Output = new Output()

The global options used for outputting Base, Range, and Values which may be overridden by specifying any number of options.

see

Base.output

see

Range.output

see

Value.output

Static globalSort

globalSort: Sort = new Sort()

The global sort options used for ordering ranges in a Base instance.

see

Base.sort

Static globalTransform

globalTransform: Transform = new Transform()

The global transform options used for transforming a Base instance by specifying what sort of units/groups are visible to the user.

see

Base.normalize

see

Base.compact

see

Base.expand

see

Base.conversions

see

Base.filter

Static unitToGroup

unitToGroup: GroupMap

A map of groups by their acceptable units.

Methods

Static addClass

  • addClass(parent: Class): void
  • Adds the given class and all groups and units to the global state. If there are units mapped to other groups they are overwritten by the units in the given class.

    Parameters

    • parent: Class

      The class to add to the global state.

    Returns void

Static addClasses

  • addClasses(...classes: Class[]): void

Static addDynamicUnit

  • addDynamicUnit(unit: string, group: Group): Group
  • Adds the unit to the given dynamic group. This function also updates the plurality of all the units currently in the group.

    Parameters

    • unit: string

      The unit to add to the given group.

    • group: Group

      The dynamically created group.

    Returns Group

    The instance of the given group.

Static getDynamicMatch

  • getDynamicMatch(unit: string): string
  • The function which takes a unit and generates a string which should be used to mark similarly spelled units under the same dynamic group.

    Parameters

    • unit: string

      The unit to build a key from.

    Returns string

    The key which identifies the dynamic group.

Static getGroup

  • getGroup(unit: string, createDynamic?: boolean): Group
  • Returns a Group instance mapped by the given unit. If no unit is given null is returned. If the unit isn't mapped to a group a dynamic group match is looked at and if none are found and createDynamic is true a new dynamic group is created.

    see

    Core.getDynamicMatch

    see

    Core.addDynamicUnit

    see

    Core.newDynamicGroup

    Parameters

    • unit: string

      The unit of the group to get.

    • Default value createDynamic: boolean = true

      If creating a dynamic group should be created if an existing group could not be found.

    Returns Group

    The group matched to the unit or null if none was found.

Static isMoreNormal

  • The function which takes to values and determines which one is more "normal" or "human friendly".

    Parameters

    • fromValue: Value

      The most normal value found so far.

    • toValue: Value

      The value to compare to.

    • transform: Transform

      The transformation rules to guide the function to choose the more normal value.

    • forOutput: Output

      The output options to guide the function to choose the more normal value.

    Returns boolean

    True if toValue appears more normal than fromValue.

Static newDynamicGroup

  • newDynamicGroup(unit: string): Group
  • Creates a dynamic class & group based on the given unit and adds it to the global state. By default the group is marked with System.ANY, is common, and has the valid denominators 2, 3, 4, 5, 6, 8, 10.

    Parameters

    • unit: string

      The initial unit of the group to use as the name of the class and the base unit of the group.

    Returns Group

    An instance of a new Group with a new parent Class.

Static setCommon

  • setCommon(unit: string, common?: boolean): void
  • Sets whether the group associated with the given unit is common. A common group is one a user is familiar with and would be okay seeing values represented in. If a group is not found then this has no affect.

    see

    Core.getGroup

    Parameters

    • unit: string

      The unit of a group to set the common flag.

    • Default value common: boolean = true

      Whether the associated group should be common.

    Returns void

Static setDenominators

  • setDenominators(unit: string, denominators: number[]): void
  • Sets the denominators for the group associated to the given unit. Denominators are useful for calculating a fraction from a value.

    see

    Core.getGroup

    Parameters

    • unit: string

      The unit of a group to set the denominators of.

    • denominators: number[]

      The new denominators for the group.

    Returns void

Static setPreferred

  • setPreferred(unit: string): void
  • Sets the given unit as the preferred unit for the group it belongs to. If a group is not found then this has no affect.

    see

    Core.getGroup

    Parameters

    • unit: string

      The unit to mark as the preferred unit.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc