mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-16 16:16:40 +03:00
562a2d567b
This enables the eslint rule requiring jsdocs on all class
declarations, function declarations, and methods.
Unfortunately, there are two problems with this:
1. We don't use class _declarations_, we use class _expressions_,
which are not covered by this rule. So it does not enforce jsdoc at
the class level.
2. We tend to document a class at the class-level, rather than at the
constructor. But a constructor counts as a method for eslint, so it
requires docs on the constructor. There is no way to configure it to
make an exception for trivial constructors.
So for all trivial (no-argument) constructors, we add empty jsdocs:
/** */
constructor() {
This was quicker and easier than setting up some alternative plugin in
eslint to make an exception for us.
The good news is that this rule caught several undocumented parameters
and places where the jsdoc comment was malformed. So fixing those
also improves the compiler's ability to enforce types.
Change-Id: Icbc46ed690c94e53d354648a883119524f8fca45
74 lines
1.4 KiB
JavaScript
74 lines
1.4 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.ads.AdsStats');
|
|
|
|
|
|
/**
|
|
* This class tracks all the various components (some optional) that are used to
|
|
* populate |shaka.extern.AdsStats| which is passed to the app.
|
|
*
|
|
* @final
|
|
*/
|
|
shaka.ads.AdsStats = class {
|
|
/** */
|
|
constructor() {
|
|
/** @private {!Array.<number>} */
|
|
this.loadTimes_ = [];
|
|
/** @private {number} */
|
|
this.started_ = 0;
|
|
/** @private {number} */
|
|
this.playedCompletely_ = 0;
|
|
/** @private {number} */
|
|
this.skipped_ = 0;
|
|
}
|
|
|
|
/**
|
|
* Record the time it took to get the final manifest.
|
|
*
|
|
* @param {number} seconds
|
|
*/
|
|
addLoadTime(seconds) {
|
|
this.loadTimes_.push(seconds);
|
|
}
|
|
|
|
/**
|
|
* Increase the number of ads started by one.
|
|
*/
|
|
incrementStarted() {
|
|
this.started_++;
|
|
}
|
|
|
|
/**
|
|
* Increase the number of ads played completely by one.
|
|
*/
|
|
incrementPlayedCompletely() {
|
|
this.playedCompletely_++;
|
|
}
|
|
|
|
/**
|
|
* Increase the number of ads skipped by one.
|
|
*/
|
|
incrementSkipped() {
|
|
this.skipped_++;
|
|
}
|
|
|
|
/**
|
|
* Create a stats blob that we can pass up to the app. This blob will not
|
|
* reference any internal data.
|
|
*
|
|
* @return {shaka.extern.AdsStats}
|
|
*/
|
|
getBlob() {
|
|
return {
|
|
loadTimes: this.loadTimes_,
|
|
started: this.started_,
|
|
playedCompletely: this.playedCompletely_,
|
|
skipped: this.skipped_,
|
|
};
|
|
}
|
|
};
|