utils

Internal utilities.

Available through Rac.utils or rac.utils.

Methods

addConstantTo()

Adds a constant to the given object, the constant is not enumerable and not configurable.

assertBoolean(…elements) → {Boolean}

Asserts that all elements are boolean primitives, otherwise a Rac.Exception.failedAssert is thrown.

Parameters:
Name Type Attributes Description
elements Boolean <repeatable>

assertExists(…parameters) → {Boolean}

Asserts that all passed parameters are objects or primitives. If any parameter is null or undefined a Rac.Exception.failedAssert is thrown.

Parameters:
Name Type Attributes Description
parameters Object | primitive <repeatable>

assertNumber(…elements) → {Boolean}

Asserts that all elements are number primitives and not NaN, otherwise a Rac.Exception.failedAssert is thrown.

Parameters:
Name Type Attributes Description
elements Number <repeatable>

assertString(…elements) → {Boolean}

Asserts that all elements are string primitives, otherwise a Rac.Exception.failedAssert is thrown.

Parameters:
Name Type Attributes Description
elements String <repeatable>

assertType(type, …elements) → {Boolean}

Asserts that all elements are objects or the given type, otherwise a Rac.Exception.failedAssert is thrown.

When any member of elements is null or undefined, the exception is also thrown.

Parameters:
Name Type Attributes Description
type function
elements Object <repeatable>

cutDigits(number, digitsopt, nullable) → {String}

Returns a string representation of number displaying all available digits, or formmatted used fixed-point notation limited to digits.

Parameters:
Name Type Attributes Description
number Number

The number to format

digits Number <optional>
<nullable>

The amount of digits to print, or null to print all digits

isUprightText(angleTurn) → {Boolean}

Returns true if text oriented with the given angleTurn would be printed upright.

Angle turn values in the range [3/4, 1/4) are considered upright.

Parameters:
Name Type Description
angleTurn Number

The turn value of the angle to check

typeName(obj) → {String}

Returns the constructor name of obj, or its type name. Convenience function for debugging and errors.

Parameters:
Name Type Description
obj Object

An Object to get its type name