diff options
| author | Ben Beltran <ben@nsovocal.com> | 2017-08-30 00:26:01 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2017-08-30 00:26:01 -0500 |
| commit | c6425032e13c139bedd0546119f6ed1c93365822 (patch) | |
| tree | e4c02a7f4d9c650dff91c778eacc0ab80b8aee73 /lib/services | |
| parent | 11400882a21f3152c586f7f6688664577a190949 (diff) | |
Add jsdoc, fix linter
Diffstat (limited to 'lib/services')
| -rw-r--r-- | lib/services/data.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/services/data.js b/lib/services/data.js index cc6c5ee..c7f6744 100644 --- a/lib/services/data.js +++ b/lib/services/data.js @@ -1,3 +1,4 @@ +/* global WebSocket */ const internals = { kSocketLocation: 'ws://localhost:1987', @@ -18,7 +19,45 @@ const internals = { } }; +/** + * The data structure representing the sorting hat data + * + * @typedef tSortingHatData + * @type object + * @param {number} state the current state: 0 for waiting, 1 for + * polling, 2 for cool down. + * @param {string} [winner] the winner after polling, might be null if + * no winner is detected + * @param {Object.<string,tRunningAverages>} runningAverages the running averages for + * the different categories, used to render the waves + */ + +/** + * The running averages, including the current sum and count + * + * @typedef tRunningAverages + * @type object + * @param {number} sum the current total + * @param {number} count the number of samples + * @param {number} average the average (sum / count) + */ + +/** + * The main data service, connects to a socket and updates the internal + * data structure + * + * @class DataService + */ export default { + + /** + * Returns the internal data structure, intended to be used as the data + * property in vue components + * + * @memberof DataService + * @method data + * @return tSortingHatData + */ data() { if (!internals.socket) { |