Class: shaka.util.Functional

A set of functional utility functions.

Methods

(static) collapseArrays(allnon-null, partnon-null) → (non-null) {Array.<T>}

Returns the first array concatenated to the second; used to collapse an array of arrays into a single array.
Parameters:
Name Type Description
all Array.<T>
part Array.<T>
Source:
Returns:
Type
Array.<T>

(static) createFallbackPromiseChain(arraynon-null, callback) → (non-null) {Promise.<RESULT>}

Creates a promise chain that calls the given callback for each element in the array in a catch of a promise. e.g.: Promise.reject().catch(callback(array[0])).catch(callback(array[1]));
Parameters:
Name Type Description
array Array.<ELEM>
callback function(ELEM): !Promise.<RESULT>
Source:
Returns:
Type
Promise.<RESULT>

(static) isNotDuplicate(item, position, selfnon-null) → {boolean}

Used to filter out duplicates in an array. Returns true the first time the element is encountered. Returns false for all the subsequent encounters.
Parameters:
Name Type Description
item T
position number
self Array.<T>
Source:
Returns:
Type
boolean
Example
[1, 1, 2].filter(shaka.util.Functional.isNotDuplicate) -> [1, 2]

(static) isNotNull(value) → {boolean}

Returns if the given value is not null; useful for filtering out null values.
Parameters:
Name Type Description
value T
Source:
Returns:
Type
boolean

(static) noop()

A no-op function. Useful in promise chains.
Source: