refactor: refactor repo card (#1325)

* refactor: refactored repo-card

* test: fix tests

* test: fixed tests

* fix: unprovided description error
This commit is contained in:
Anurag Hazra
2021-09-26 21:02:27 +05:30
committed by GitHub
parent ec8eb0c893
commit 62d65ab483
7 changed files with 140 additions and 77 deletions
+19 -4
View File
@@ -1,6 +1,7 @@
const axios = require("axios");
const wrap = require("word-wrap");
const themes = require("../../themes");
const toEmoji = require("emoji-name-map");
const renderError = (message, secondaryMessage = "") => {
return `
@@ -88,10 +89,11 @@ function request(data, headers) {
}
/**
*
* @param {string[]} items
* @param {Number} gap
* @param {"column" | "row"} direction
* @param {object} props
* @param {string[]} props.items
* @param {number} props.gap
* @param {number[]} props.sizes
* @param {"column" | "row"} props.direction
*
* @returns {string[]}
*
@@ -257,6 +259,18 @@ function chunkArray(arr, perChunk) {
}, []);
}
/**
*
* @param {string} str
* @returns {string}
*/
function parseEmojis(str) {
if (!str) throw new Error("[parseEmoji]: str argument not provided");
return str.replace(/:\w+:/gm, (emoji) => {
return toEmoji.get(emoji) || "";
});
}
module.exports = {
renderError,
kFormatter,
@@ -276,4 +290,5 @@ module.exports = {
CustomError,
lowercaseTrim,
chunkArray,
parseEmojis,
};