Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add drawVerticalLine * Refactor * Add more test * Fix JsDoc * Add tests for drawBorder funcs Co-authored-by: Nam Hoang Le <nam.hoang.le@mgm-tp.com>
- Loading branch information
Showing
17 changed files
with
514 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @typedef {object} drawHorizontalContent~separator | ||
* @property {string} left | ||
* @property {string} right | ||
* @property {string} join | ||
*/ | ||
|
||
/** | ||
* @param {string[]} columns | ||
* @param {object} config | ||
* @param {drawHorizontalContent~separator} config.separator | ||
* @param {Function} config.drawVerticalLine | ||
* @returns {string} | ||
*/ | ||
export default (columns, {separator, drawVerticalLine}) => { | ||
const columnCount = columns.length; | ||
const result = []; | ||
|
||
result.push(drawVerticalLine(0, columnCount) ? separator.left : ''); | ||
|
||
columns.forEach((column, index) => { | ||
result.push(column); | ||
|
||
if (index + 1 < columnCount) { | ||
result.push(drawVerticalLine(index + 1, columnCount) ? separator.join : ''); | ||
} | ||
}); | ||
result.push(drawVerticalLine(columnCount, columnCount) ? separator.right : ''); | ||
|
||
return result.join('') + '\n'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.