Options
All
  • Public
  • Public/Protected
  • All
Menu

The class which takes user input and parses it to specific structures.

Hierarchy

  • Parse

Index

Properties

Static REGEX_LIST

REGEX_LIST: RegExp = /\s*,\s*/

The regular expression used to split up a string into multiple ranges.

Static REGEX_PARSE

REGEX_PARSE: RegExp = /^\s*(-?\d*)(\s+(\d+))?(\s*\/\s*(\d+)|\.(\d+)|)\s*(.*)\s*$/i

The regular expression used to parse a value number or fraction and possible unit from a string.

Static REGEX_RANGE

REGEX_RANGE: RegExp = /\s*(-?[^-]+)-(.+)/

The regular expression used to split up a range string to determine the min and maximum values.

Static REGEX_UNIT

REGEX_UNIT: RegExp = /\s*(\/|\s+per\s+)\s*/i

The regular expression used to split up a unit from a rateUnit.

Methods

Static base

  • Parses user input into a Base instance.

    Parameters

    • input: BaseInput

      The input to parse into a Base.

    Returns Base

    The instance parsed from the input.

Static input

  • Parses user input into a ParseResult. If the input is not valid null is returned.

    Examples:

    • 1tsp
    • 1 tsp
    • 1/2 tsp
    • 1 1/2 tsp
    • -2 cups
    • 2.35"

    Parameters

    • input: string

      The string to parse a value and unit from.

    Returns ParseResult

    The result of the parsing.

Static range

Static rangeFromString

  • rangeFromString(input: string): Range
  • Parses user input into a Range.

    Parameters

    • input: string

      The input to parse.

    Returns Range

    The instance parsed from the input.

Static ranges

Static rangesFromArray

  • Parses user input into a an array of Ranges.

    Parameters

    Returns RangeList

    The instances parsed from the input.

Static rangesFromString

  • Parses user input into a an array of Ranges.

    Parameters

    • input: string

      The input to parse.

    Returns RangeList

    The instances parsed from the input.

Static unit

  • unit(input: string): Rate
  • Parses unit input into a Rate.

    Examples:

    • m/s
    • miles per hour
    • mph

    Parameters

    • input: string

      The string to parse a unit from.

    Returns Rate

    The result of the parsing.

Static value

Static valueFromResult

  • Parses user input into a Value.

    Parameters

    • result: ParseResult

      The already parsed input.

    • unit: string

      The unit parsed from the input.

    • rateUnit: string

    Returns Value

    The instance parsed from the input.

Static valueFromString

  • valueFromString(input: string): Value
  • Parses user input into a Value.

    Parameters

    • input: string

      The input to parse.

    Returns Value

    The instance parsed from the input.

Static valueFromValue

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