Remove several redundant number -> string -> number conversions (#2856)

* Top langs card: remove redundant number -> string -> number conversion

* refactor(waka): remove redundant praseInt

---------

Co-authored-by: rickstaa <rick.staa@outlook.com>
This commit is contained in:
Alexandr Garbuzov 2023-06-19 13:45:49 +03:00 committed by GitHub
parent 9a1cbaf062
commit 62080c019c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -164,14 +164,14 @@ const donutCenterTranslation = (totalLangs) => {
* Trim top languages to lang_count while also hiding certain languages.
*
* @param {Record<string, Lang>} topLangs Top languages.
* @param {string} langs_count Number of languages to show.
* @param {number} langs_count Number of languages to show.
* @param {string[]=} hide Languages to hide.
* @returns {{ langs: Lang[], totalLanguageSize: number }} Trimmed top languages and total size.
*/
const trimTopLanguages = (topLangs, langs_count, hide) => {
let langs = Object.values(topLangs);
let langsToHide = {};
let langsCount = clampValue(parseInt(langs_count), 1, MAXIMUM_LANGS_COUNT);
let langsCount = clampValue(langs_count, 1, MAXIMUM_LANGS_COUNT);
// populate langsToHide map for quick lookup
// while filtering out
@ -734,7 +734,7 @@ const renderTopLanguages = (topLangs, options = {}) => {
const { langs, totalLanguageSize } = trimTopLanguages(
topLangs,
String(langs_count),
langs_count,
hide,
);

View file

@ -204,7 +204,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
const lheight = parseInt(String(line_height), 10);
const langsCount = clampValue(parseInt(String(langs_count)), 1, langs_count);
const langsCount = clampValue(langs_count, 1, langs_count);
// returns theme based colors with proper overrides and defaults
const { titleColor, textColor, iconColor, bgColor, borderColor } =