Class: shaka.util.Functional

A set of functional utility functions.

Constructor

new Functional()

A set of functional utility functions.

Source:

Methods

collapseArrays(allnon-null, partnon-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>

createFallbackPromiseChain(arraynon-null, callback) → {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>

ignored(…args)

A no-op function that ignores its arguments. This is used to suppress unused variable errors.
Parameters:
Name Type Attributes Description
args * <repeatable>
Source:

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

noop()

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

promiseWithTimeout(seconds, asyncProcessnon-null) → {Promise.<T>}

Returns a Promise which is resolved only if |asyncProcess| is resolved, and only if it is resolved in less than |seconds| seconds. If the returned Promise is resolved, it returns the same value as |asyncProcess|. If |asyncProcess| fails, the returned Promise is rejected. If |asyncProcess| takes too long, the returned Promise is rejected, but |asyncProcess| is still allowed to complete.
Parameters:
Name Type Description
seconds number
asyncProcess Promise.<T>
Source:
Returns:
Type
Promise.<T>