Type

Type module

Sources

Items from Type can be imported/included and used via following ways.

/**
 * --------------------------------------------------------
 * Import via main package: core.ts
 * Access items like: am4core.type.myVariable
 *                    am4core.type.myFunction()
 * --------------------------------------------------------
 */
import * as am4core from "@amcharts/amcharts4";

/**
 * --------------------------------------------------------
 * Import via: Type.ts
 * Access items like: $type.myVariable
 *                    $type.myFunction()
 * --------------------------------------------------------
 */
import * as $type from "@amcharts/amcharts4/Type";

/**
 * --------------------------------------------------------
 * Include via "core.js"
 * Access items like: am4core.type.myVariable
 *                    am4core.type.myFunction()
 * --------------------------------------------------------
 */

Variables

Type does not have any variables.

Functions

castNumber(

value: string | number | Date

)

#

Returns number

Casts string or a number into a number.

@throws {Error}

castString(

value: string | number

)

#

Returns string

Casts string or a number into string.

@deprecated Not used anywhere

checkArray(

value: Array < A >

)

#

Returns value

Checks if the passed in value is an array.

@throws {Error}
@deprecated Not used anywhere

checkBoolean(

value: any

)

#

Returns value

Checks if the passed in value is a boolean.

@throws {Error}
@deprecated Not used anywhere

checkDate(

value: Date

)

#

Returns value

Checks if the passed in value is a Date object.

@throws {Error}
@deprecated Not used anywhere

checkNumber(

value: any

)

#

Returns value

Checks if the passed in value is a number.

@throws {Error}

checkObject(

value: object

)

#

Returns value

Checks if the passed in value is an object.

@throws {Error}
@todo Is the input type correct?
@deprecated Not used anywhere

checkString(

value: any

)

#

Returns value

Checks if the passed in value is a string.

@throws {Error}
@deprecated Not used anywhere

getDefault(

value: null | undefined | A,
optional: A

)

#

Returns A

Returns a default value if the passed in value is empty.

@deprecated Not used anywhere

getType(

value: A

)

#

Returns Type

Returns a type of the value.

getValue(

a: Optional < A > | null

)

#

Returns A

Returns a value or throws an {Error} exception if the variable has not value.

getValueDefault(

a: Optional < A > | null,
defaultValue: A

)

#

Returns A

Returns a value, or returns the default value if it doesn't have a value.

hasValue(

a: Optional < A > | null

)

#

Returns a

Checks if a variable has a value.

isArray(

value: any

)

#

Returns value

Checks if parameter is Array.

isDate(

value: any

)

#

Returns value

Checks if parameter is Date.

isNaN(

value: number

)

#

Returns boolean

Returns true if value is not a number (NaN).

@deprecated Is not used anywhere. JS built-in isNaN is used everywhere. Maybe we don't need this, or if we do, then we should use it everywhere

isNumber(

value: any

)

#

Returns value

Checks if parameter is number.

isObject(

value: any

)

#

Returns value

Checks if parameter is object.

isString(

value: any

)

#

Returns value

Checks if parameter is string.

toBoolean(

value: any

)

#

Returns boolean

Converts any value into boolean.

toNumber(

value: any

)

#

Returns number

Converts any value into a number.

toNumberOrPercent(

value: any

)

#

Returns number | Percent

Converts any value to a number or Percent.

If the parameter is a string and contains "%", it will convert it into a Percent.

Otherwise, it will convert into a number.

toText(

value: any

)

#

Returns string

Converts any value into a string (text).