Provides functional transformations for numbers within HotMesh mapping rules. These functions facilitate the manipulation and transformation of numbers during the mapping process. Although inspired by JavaScript, they have been adapted to follow a functional approach. Each transformation is a function that expects one or more input parameters from the prior row in the @pipe structure.

Invoked via {@number.<method>} in YAML mapping rules.

Constructors

Methods

  • Checks if a number is strictly greater than a comparison value.

    Parameters

    • input: number

      The number to compare

    • compareValue: number

      The value to compare against

    Returns boolean

    True if input is greater than compareValue

    is_gt:
    "@pipe":
    - ["{a.output.data.value}", 10]
    - ["{@number.gt}"]
  • Checks if a number is greater than or equal to a comparison value.

    Parameters

    • input: number

      The number to compare

    • compareValue: number

      The value to compare against

    Returns boolean

    True if input is greater than or equal to compareValue

    is_gte:
    "@pipe":
    - ["{a.output.data.value}", 10]
    - ["{@number.gte}"]
  • Checks if a number is even.

    Parameters

    • input: number

      The number to check

    Returns boolean

    True if the number is even, otherwise false

    is_even:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@number.isEven}"]
  • Checks if a number is finite. Returns false for Infinity, -Infinity, and NaN.

    Parameters

    • input: number

      The number to check

    Returns boolean

    True if the number is finite, otherwise false

    is_finite:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@number.isFinite}"]
  • Checks if a number is an integer (has no fractional component).

    Parameters

    • input: number

      The number to check

    Returns boolean

    True if the number is an integer, otherwise false

    is_integer:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@number.isInteger}"]
  • Checks if the given value is NaN (Not-a-Number).

    Parameters

    • input: number

      The value to check

    Returns boolean

    True if the value is NaN, otherwise false

    is_nan:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@number.isNaN}"]
  • Checks if a number is odd.

    Parameters

    • input: number

      The number to check

    Returns boolean

    True if the number is odd, otherwise false

    is_odd:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@number.isOdd}"]
  • Checks if a number is strictly less than a comparison value.

    Parameters

    • input: number

      The number to compare

    • compareValue: number

      The value to compare against

    Returns boolean

    True if input is less than compareValue

    is_lt:
    "@pipe":
    - ["{a.output.data.value}", 10]
    - ["{@number.lt}"]
  • Checks if a number is less than or equal to a comparison value.

    Parameters

    • input: number

      The number to compare

    • compareValue: number

      The value to compare against

    Returns boolean

    True if input is less than or equal to compareValue

    is_lte:
    "@pipe":
    - ["{a.output.data.value}", 10]
    - ["{@number.lte}"]
  • Returns the largest of the provided numbers.

    Parameters

    • Rest...values: number[]

      The numbers to compare

    Returns number

    The largest number among the provided values

    maximum:
    "@pipe":
    - ["{a.output.data.val1}", "{a.output.data.val2}", "{a.output.data.val3}"]
    - ["{@number.max}"]
  • Returns the smallest of the provided numbers.

    Parameters

    • Rest...values: number[]

      The numbers to compare

    Returns number

    The smallest number among the provided values

    minimum:
    "@pipe":
    - ["{a.output.data.val1}", "{a.output.data.val2}", "{a.output.data.val3}"]
    - ["{@number.min}"]
  • Parses a string and returns a floating-point number.

    Parameters

    • input: string

      The string to parse

    Returns number

    The parsed floating-point number, or NaN if the string cannot be parsed

    float_value:
    "@pipe":
    - ["{a.output.data.string_value}"]
    - ["{@number.parseFloat}"]
  • Parses a string and returns an integer of the specified radix (base).

    Parameters

    • input: string

      The string to parse

    • Optionalradix: number

      The radix (base) to use for parsing (e.g., 10 for decimal, 16 for hexadecimal)

    Returns number

    The parsed integer, or NaN if the string cannot be parsed

    decimal_value:
    "@pipe":
    - ["{a.output.data.hex_value}", 16]
    - ["{@number.parseInt}"]
  • Returns the base raised to the exponent power.

    Parameters

    • base: number

      The base number

    • exponent: number

      The exponent to raise the base to

    Returns number

    The result of base raised to the power of exponent

    power:
    "@pipe":
    - ["{a.output.data.base}", "{a.output.data.exponent}"]
    - ["{@number.pow}"]
  • Rounds a number to the nearest integer.

    Parameters

    • input: number

      The number to round

    Returns number

    The value of the number rounded to the nearest integer

    rounded:
    "@pipe":
    - ["{a.output.data.value}"]
    - ["{@number.round}"]
  • Formats a number using exponential (scientific) notation with a specified number of fractional digits.

    Parameters

    • input: number

      The number to format

    • OptionalfractionalDigits: number

      The number of digits after the decimal point

    Returns string

    A string representing the number in exponential notation

    exponential_value:
    "@pipe":
    - ["{a.output.data.value}", 2]
    - ["{@number.toExponential}"]
  • Formats a number using fixed-point notation with a specified number of digits after the decimal point.

    Parameters

    • input: number

      The number to format

    • Optionaldigits: number

      The number of digits to appear after the decimal point

    Returns string

    A string representing the number in fixed-point notation

    fixed_value:
    "@pipe":
    - ["{a.output.data.value}", 2]
    - ["{@number.toFixed}"]
  • Formats a number to a specified precision (total number of significant digits), using either fixed-point or exponential notation depending on the value.

    Parameters

    • input: number

      The number to format

    • Optionalprecision: number

      The number of significant digits

    Returns string

    A string representing the number to the specified precision

    precise_value:
    "@pipe":
    - ["{a.output.data.value}", 4]
    - ["{@number.toPrecision}"]