From 67d62fa9f8c9e1e7c7db714b85aa19e6b897a2d0 Mon Sep 17 00:00:00 2001 From: ArtemBaskal Date: Fri, 5 Jun 2020 11:53:47 +0300 Subject: [PATCH] Fix jsdocs of helpers --- client/src/helpers/helpers.js | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index bb0dbe55511..be8e884eaa9 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -30,8 +30,8 @@ import { } from './constants'; /** - * @param string The time to format - * @returns string Returns the time in the format HH:mm:ss + * @param time {string} The time to format + * @returns {string} Returns the time in the format HH:mm:ss */ export const formatTime = (time) => { const parsedTime = dateParse(time); @@ -39,8 +39,9 @@ export const formatTime = (time) => { }; /** - * @param string The date to format - * @returns string Returns the date and time in the format DD/MM/YYYY, HH:mm + * @param dateTime {string} The date to format + * @param [options] {object} Date.prototype.toLocaleString([locales[, options]]) options argument + * @returns {string} Returns the date and time in the specified format */ export const formatDateTime = (dateTime, options = DEFAULT_DATE_FORMAT_OPTIONS) => { const { language } = navigator; @@ -51,13 +52,17 @@ export const formatDateTime = (dateTime, options = DEFAULT_DATE_FORMAT_OPTIONS) return parsedTime.toLocaleString(currentLanguage, options); }; +/** + * @param dateTime {string} The date to format + * @returns {string} Returns the date and time in the format with the full month name + */ export const formatDetailedDateTime = (dateTime) => formatDateTime( dateTime, DETAILED_DATE_FORMAT_OPTIONS, ); /** - * @param string - * @returns boolean + * @param date {string} + * @returns {boolean} */ export const isToday = (date) => isSameDay(new Date(date), new Date()); @@ -309,15 +314,12 @@ export const normalizeTextarea = (text) => { * @returns {Object.} normalizedTopClients.auto - auto clients * @returns {Object.} normalizedTopClients.configured - configured clients */ - export const normalizeTopClients = (topClients) => topClients.reduce( - (nameToCountMap, clientObj) => { + (acc, clientObj) => { const { name, count, info: { name: infoName } } = clientObj; - // eslint-disable-next-line no-param-reassign - nameToCountMap.auto[name] = count; - // eslint-disable-next-line no-param-reassign - nameToCountMap.configured[infoName] = count; - return nameToCountMap; + acc.auto[name] = count; + acc.configured[infoName] = count; + return acc; }, { auto: {}, configured: {}, @@ -485,8 +487,8 @@ export const getCurrentFilter = (url, filters) => { }; /** - * @param {object} initialValues - * @param {object} values + * @param initialValues {object} + * @param values {object} * @returns {object} Returns different values of objects */ export const getObjDiff = (initialValues, values) => Object.entries(values) @@ -498,8 +500,8 @@ export const getObjDiff = (initialValues, values) => Object.entries(values) }, {}); /** - * @param number Number to format - * @returns string Returns a string with a language-sensitive representation of this number + * @param num {number} to format + * @returns {string} Returns a string with a language-sensitive representation of this number */ export const formatNumber = (num) => { const currentLanguage = i18n.languages[0] || DEFAULT_LANGUAGE; @@ -510,7 +512,6 @@ export const normalizeMultiline = (multiline) => `${normalizeTextarea(multiline) .map((line) => line.trim()) .join('\n')}\n`; - /** * @param parsedIp {object} ipaddr.js IPv4 or IPv6 object * @param cidr {array} ipaddr.js CIDR array