Home Manual Reference Source
import Helpers from 'pvbid-sdk/src/utils/Helpers.js'
public class | source

Helpers

Static Member Summary

Static Public Members
public static

Static Method Summary

Static Public Methods
public static

Calculate the value of the given formula

public static

Converts any value to a finite number.

public static

evalExpression(formula: string, valueMap: object): boolean

Evaluate the logical expression

public static

Determines if value is a finite number.

public static

Parse the variables referenced in a formula

public static

union(iterables: ...*): *

public static

validateFormula(formula: *, valuesMap: *): *

FIXME don't think there is a good way to validate without just eval'ing with the variables substituted in.

Constructor Summary

Public Constructor
public

Static Public Members

public static applyCeiling: * source

Static Public Methods

public static calculateFormula(formula: string, valuesMap: Object<string, number|boolean|string>, options: object): number | boolean | string source

Calculate the value of the given formula

Params:

NameTypeAttributeDescription
formula string

formula to evaluate

valuesMap Object<string, number|boolean|string>
options object
options.castValuesToNumbers boolean
  • optional
  • default: true

flag forces all non-number values to be treated as numbers

Return:

number | boolean | string

the calculated value of the formula

public static confirmNumber(val: number | string | boolean, dflt: number): number source

Converts any value to a finite number. If the value can not be converted it will use the default value. Booleans are converted to 1 or 0.

Params:

NameTypeAttributeDescription
val number | string | boolean
dflt number
  • optional
  • default: 0

Return:

number

public static evalExpression(formula: string, valueMap: object): boolean source

Evaluate the logical expression

Params:

NameTypeAttributeDescription
formula string
valueMap object

Return:

boolean

public static isNumber(val: string | number): boolean source

Determines if value is a finite number.

Params:

NameTypeAttributeDescription
val string | number

Return:

boolean

public static parseFormulaArguments(formula: string): string[] source

Parse the variables referenced in a formula

Params:

NameTypeAttributeDescription
formula string

Return:

string[]

Array of variables referenced in the formula

public static union(iterables: ...*): * source

Params:

NameTypeAttributeDescription
iterables ...*

Return:

*

public static validateFormula(formula: *, valuesMap: *): * source

FIXME don't think there is a good way to validate without just eval'ing with the variables substituted in.

Params:

NameTypeAttributeDescription
formula *
valuesMap *

Return:

*

Public Constructors

public constructor() source