App Connect Data Formatters - Numeric

Intro

Below is a comprehensive list of Numeric data formatters available in App Connect (client-side), accompanied by explanations outlining the purpose and functionality of each.

Numeric Formatters

In Range:

  • Checks if the given number is between the specified minimum and maximum values.
  • Example: (5).inRange(1, 10) returns true

Absolute Value:

  • Returns the absolute value of the given number.
  • Example: (-7).abs() returns 7

Ceil:

  • Rounds the given number up to the nearest integer.
  • Example: (5.2).ceil() returns 6

Floor:

  • Rounds the given number down to the nearest integer.
  • Example: (5.8).floor() returns 5

Max:

  • Returns the larger of the given number and another number.
  • Example: (5).max(8) returns 8

Min:

  • Returns the smaller of the given number and another number.
  • Example: (5).min(3) returns 3

Power:

  • Raises the given number to the specified exponent.
  • Example: (2).pow(3) returns 8

Percentage Of:

  • Calculates a percentage of a number.
  • Example: (50).per(10) returns 5

Ratio Of Total:

  • Returns the ratio of the number relative to a total.
  • Example: (25).perOf(100) returns 0.25

Round:

  • Rounds the number to a specified precision.
  • Example: (5.678).round(2) returns 5.68

Pad Number:

  • Pads the number with leading zeros.
  • Example: (7).pad(3) returns '007'

To Fixed:

  • Formats the number using fixed decimal places.
  • Example: (5.1).toFixed(2) returns '5.10'

Format Number:

  • Formats a number with custom decimals, separators and delimiters.
  • Example: (12345.678).formatNumber(2, '.', ',') returns '12,345.68'

Format Percentage:

  • Formats a number as a percentage.
  • Example: (0.25).formatPercentage(2) returns '25.00%'

Format Currency:

  • Formats a number as currency.
  • Example: (1234.56).formatCurrency('$', '.', ',', 2) returns '$1,234.56'

Format Size:

  • Formats a number as a human-readable file size.
  • Example: (1024).formatSize(2, true) returns '1.00 KiB'
2 Likes