helpers

helpers

Source:

Methods

# (static) exports.format(value, precision) → {number}

Formats and rounds a number to the required precision.
Parameters:
Name Type Description
value number The value to be formatted.
precision number 0 to 100 number of floating point digits. Default 2.
Source:
Returns:
The formatted number.
Type
number
Example
format(1.434);       // 1.43
format(1.436);       // 1.44
format("1.432");     // 1.43
format("1.432", 1);  // 1.4
format("1.432", 0);  // 1
format("1.6", 0);    // 2
format(1, 100);      // 1

# (static) exports.isGreaterThanZero(input, name, strict) → {boolean}

Checks if the given input is greater than 0. Throws an error or returns boolean if strict parameter is passed as false.
Parameters:
Name Type Description
input number Input value
name string Variable name
strict boolean Set to false if you need an exception instead. Default true
Source:
Throws:
When input < 0
Type
Error
Returns:
Type
boolean
Example
// throws 'Radius must be greater than 0.'
this._isGreaterThanZero(-1, 'Radius');

// returns false
this._isGreaterThanZero(-1, 'Radius', false);

// passes
this._isGreaterThanZero(1, 'Area');

// returns true
this._isGreaterThanZero(1, 'Area', false);