Skip to content

Commit

Permalink
Fix jsdocs of helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemBaskal committed Jun 5, 2020
1 parent 459e3cf commit 67d62fa
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions client/src/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ 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);
return dateFormat(parsedTime, DEFAULT_TIME_FORMAT);
};

/**
* @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;
Expand All @@ -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());

Expand Down Expand Up @@ -309,15 +314,12 @@ export const normalizeTextarea = (text) => {
* @returns {Object.<string, number>} normalizedTopClients.auto - auto clients
* @returns {Object.<string, number>} 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: {},
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 67d62fa

Please sign in to comment.