/** @license
 * Copyright 2016 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

goog.provide('shaka.polyfill');

goog.require('shaka.util.Iterables');


/**
 * @summary A one-stop installer for all polyfills.
 * @see http://enwp.org/polyfill
 * @exportDoc
 */
shaka.polyfill = class {
  /**
   * Install all polyfills.
   * @export
   */
  static installAll() {
    for (const polyfill of shaka.polyfill.polyfills_) {
      polyfill.callback();
    }
  }

  /**
   * Registers a new polyfill to be installed.
   *
   * @param {function()} polyfill
   * @param {number=} priority An optional number priority.  Higher priorities
   *   will be executed before lower priority ones.  Default is 0.
   * @export
   */
  static register(polyfill, priority) {
    const newItem = {priority: priority || 0, callback: polyfill};
    const enumerate = (it) => shaka.util.Iterables.enumerate(it);
    for (const {i, item} of enumerate(shaka.polyfill.polyfills_)) {
      if (item.priority < newItem.priority) {
        shaka.polyfill.polyfills_.splice(i, 0, newItem);
        return;
      }
    }
    shaka.polyfill.polyfills_.push(newItem);
  }
};


/**
 * Contains the polyfills that will be installed.
 * @private {!Array.<{priority: number, callback: function()}>}
 */
shaka.polyfill.polyfills_ = [];

/** @license
 * Copyright 2016 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

goog.provide('shaka.polyfill');

goog.require('shaka.util.Iterables');


/**
 * @summary A one-stop installer for all polyfills.
 * @see http://enwp.org/polyfill
 * @exportInterface
 */
shaka.polyfill = class {
  /**
   * Install all polyfills.
   * @export
   */
  static installAll() {
    for (const polyfill of shaka.polyfill.polyfills_) {
      polyfill.callback();
    }
  }

  /**
   * Registers a new polyfill to be installed.
   *
   * @param {function()} polyfill
   * @param {number=} priority An optional number priority.  Higher priorities
   *   will be executed before lower priority ones.  Default is 0.
   * @export
   */
  static register(polyfill, priority) {
    const newItem = {priority: priority || 0, callback: polyfill};
    const enumerate = (it) => shaka.util.Iterables.enumerate(it);
    for (const {i, item} of enumerate(shaka.polyfill.polyfills_)) {
      if (item.priority < newItem.priority) {
        shaka.polyfill.polyfills_.splice(i, 0, newItem);
        return;
      }
    }
    shaka.polyfill.polyfills_.push(newItem);
  }
};


/**
 * Contains the polyfills that will be installed.
 * @private {!Array.<{priority: number, callback: function()}>}
 */
shaka.polyfill.polyfills_ = [];

Fix shaka.polyfill missing in externs
Fix shaka.polyfill missing in externs

The generated externs did not include shaka.polyfill because we used
the wrong annotation on the class.  This fixes it.

Raised in PR #1273

Change-Id: I348064a117a7e1878b439ad8bd1ce49df56bfd39
