Class: shaka.util.MapUtils

A set of map/object utility functions.

Source:

Methods

(static) empty(objectnon-null) → {boolean}

Returns true if the map is empty; otherwise, returns false.
Parameters:
Name Type Description
object Object.<string, T>
Source:
Returns:
Type
boolean

(static) getAsInstanceType(objectnon-null, key, constructor) → {T}

Gets a value that is an instance of the specified class.
Parameters:
Name Type Description
object Object.<string, *>
key string
constructor function(new:T) | function(new:T, ...[*]) The class's constructor.
Source:
Throws:
TypeError if the value is not an instance of the specified class.
Returns:
The value if the value exists and is an instance of the specified class; otherwise, return null if the value does not exist.
Type
T

(static) getAsPrimitiveType(objectnon-null, key, typeName) → {*}

Gets a value that has the specified primitive type
Parameters:
Name Type Description
object Object.<string, *>
key string
typeName string The primitive type's name, e.g., 'boolean'.
Source:
Throws:
TypeError if the value does not have the specified type.
Returns:
The value if the value exists and has the specified type; otherwise, return null if the value does not exist.
Type
*

(static) getBoolean(objectnon-null, key) → (nullable) {boolean}

Gets a boolean value.
Parameters:
Name Type Description
object Object.<string, *>
key string
Source:
Throws:
TypeError if the value is not a boolean value.
Returns:
The value if the value exists and is a boolean value; otherwise, return null if the value does not exist.
Type
boolean

(static) getNumber(objectnon-null, key, opt_lowerBoundopt, opt_upperBoundopt) → (nullable) {number}

Gets a number value.
Parameters:
Name Type Attributes Description
object Object.<string, *>
key string
opt_lowerBound number <optional>
Optional lower bound (inclusive).
opt_upperBound number <optional>
Optional upper bound (inclusive).
Source:
Throws:
  • TypeError if the value is not a number value.
  • RangeError if the value is not finite or within the given bounds, if any.
Returns:
The value if the value exists and is a number value that is finite and within the given bounds, if any; otherwise, return null if the value does not exist.
Type
number

(static) getString(objectnon-null, key) → (nullable) {string}

Gets a string value.
Parameters:
Name Type Description
object Object.<string, *>
key string
Source:
Throws:
TypeError if the value is not a string value.
Returns:
The value if the value exists and is a string value; otherwise, return null if the value does not exist.
Type
string

(static) values(objectnon-null) → (non-null) {Array.<T>}

Gets the map's values.
Parameters:
Name Type Description
object Object.<string, T>
Source:
Returns:
Type
Array.<T>