mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-14 15:56:38 +03:00
ac5acc80cb
Below are the changelog entries for each deprecated feature removed by this commit. ----- feat(config)!: `manifest.dash.defaultPresentationDelay` has been replaced by `manifest.defaultPresentationDelay` (deprecated in v3.0.0) feat(config)!: Configuration of factories should be plain factory functions, not constructors; these will not be invoked with `new` (deprecated in v3.1.0) feat(player)!: `shaka.Player.prototype.addTextTrack()` has been replaced by `addTextTrackAsync()`, which returns a `Promise` (deprecated in v3.1.0) feat(ui)!: `shaka.ui.TrackLabelFormat` has been renamed to `shaka.ui.Overlay.TrackLabelFormat` (deprecated in v3.1.0) feat(ui)!: `shaka.ui.FailReasonCode` has been renamed to `shaka.ui.Overlay.FailReasonCode` (deprecated in v3.1.0) feat(offline)!: `shaka.offline.Storage.prototype.store()` returns `AbortableOperation` instead of `Promise` (deprecated in v3.0.0) feat(offline)!: `shaka.offline.Storage.prototype.getStoreInProgress()` has been removed; concurrent operations are supported, so callers don't need to check this (deprecated in v3.0.0) feat!: `shaka.util.Uint8ArrayUtils.equal` has been replaced by `shaka.util.BufferUtils.equal`, which can handle multiple types of buffers (deprecated in v3.0.0) feat(manifest)!: `shaka.media.SegmentIndex.prototype.destroy()` has been replaced by `release()`, which is synchronous (deprecated in v3.0.0) feat(manifest)!: `shaka.media.SegmentIterator.prototype.seek()`, which mutates the iterator, has been replaced by `shaka.media.SegmentIndex.getIteratorForTime()` (deprecated in v3.1.0) feat(manifest)!: `shaka.media.SegmentIndex.prototype.merge()` has become private; use `mergeAndEvict()` instead (deprecated in v3.2.0) feat(plugin)!: `AbrManager` plugins must implement the `playbackRateChanged()` method (deprecated in v3.0.0) feat(plugin)!: `shaka.extern.Cue.prototype.spacer` has been replaced by the more clearly-named `lineBreak` (deprecated in v3.1.0) feat(plugin)!: `IUIElement` plugins must have a `release()` method (not `destroy()`) (deprecated in v3.0.0)
71 lines
1.5 KiB
JavaScript
71 lines
1.5 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.util.Functional');
|
|
|
|
/**
|
|
* @summary A set of functional utility functions.
|
|
*/
|
|
shaka.util.Functional = class {
|
|
/**
|
|
* 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]));
|
|
*
|
|
* @param {!Array.<ELEM>} array
|
|
* @param {function(ELEM):!Promise.<RESULT>} callback
|
|
* @return {!Promise.<RESULT>}
|
|
* @template ELEM,RESULT
|
|
*/
|
|
static createFallbackPromiseChain(array, callback) {
|
|
return array.reduce((promise, elem) => {
|
|
return promise.catch(() => callback(elem));
|
|
}, Promise.reject());
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the first array concatenated to the second; used to collapse an
|
|
* array of arrays into a single array.
|
|
*
|
|
* @param {!Array.<T>} all
|
|
* @param {!Array.<T>} part
|
|
* @return {!Array.<T>}
|
|
* @template T
|
|
*/
|
|
static collapseArrays(all, part) {
|
|
return all.concat(part);
|
|
}
|
|
|
|
/**
|
|
* A no-op function that ignores its arguments. This is used to suppress
|
|
* unused variable errors.
|
|
* @param {...*} args
|
|
*/
|
|
static ignored(...args) {}
|
|
|
|
|
|
/**
|
|
* A no-op function. Useful in promise chains.
|
|
*/
|
|
static noop() {}
|
|
|
|
|
|
/**
|
|
* Returns if the given value is not null; useful for filtering out null
|
|
* values.
|
|
*
|
|
* @param {T} value
|
|
* @return {boolean}
|
|
* @template T
|
|
*/
|
|
static isNotNull(value) {
|
|
return value != null;
|
|
}
|
|
};
|