You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.3 KiB

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = void 0;
  6. /**
  7. * @typedef drawBorder~parts
  8. * @property {string} left
  9. * @property {string} right
  10. * @property {string} body
  11. * @property {string} join
  12. */
  13. /**
  14. * @param {number[]} columnSizeIndex
  15. * @param {drawBorder~parts} parts
  16. * @returns {string}
  17. */
  18. const drawBorder = (columnSizeIndex, parts) => {
  19. const columns = columnSizeIndex.map(size => {
  20. return parts.body.repeat(size);
  21. }).join(parts.join);
  22. return parts.left + columns + parts.right + '\n';
  23. };
  24. /**
  25. * @typedef drawBorderTop~parts
  26. * @property {string} topLeft
  27. * @property {string} topRight
  28. * @property {string} topBody
  29. * @property {string} topJoin
  30. */
  31. /**
  32. * @param {number[]} columnSizeIndex
  33. * @param {drawBorderTop~parts} parts
  34. * @returns {string}
  35. */
  36. exports.drawBorder = drawBorder;
  37. const drawBorderTop = (columnSizeIndex, parts) => {
  38. const border = drawBorder(columnSizeIndex, {
  39. body: parts.topBody,
  40. join: parts.topJoin,
  41. left: parts.topLeft,
  42. right: parts.topRight
  43. });
  44. if (border === '\n') {
  45. return '';
  46. }
  47. return border;
  48. };
  49. /**
  50. * @typedef drawBorderJoin~parts
  51. * @property {string} joinLeft
  52. * @property {string} joinRight
  53. * @property {string} joinBody
  54. * @property {string} joinJoin
  55. */
  56. /**
  57. * @param {number[]} columnSizeIndex
  58. * @param {drawBorderJoin~parts} parts
  59. * @returns {string}
  60. */
  61. exports.drawBorderTop = drawBorderTop;
  62. const drawBorderJoin = (columnSizeIndex, parts) => {
  63. return drawBorder(columnSizeIndex, {
  64. body: parts.joinBody,
  65. join: parts.joinJoin,
  66. left: parts.joinLeft,
  67. right: parts.joinRight
  68. });
  69. };
  70. /**
  71. * @typedef drawBorderBottom~parts
  72. * @property {string} topLeft
  73. * @property {string} topRight
  74. * @property {string} topBody
  75. * @property {string} topJoin
  76. */
  77. /**
  78. * @param {number[]} columnSizeIndex
  79. * @param {drawBorderBottom~parts} parts
  80. * @returns {string}
  81. */
  82. exports.drawBorderJoin = drawBorderJoin;
  83. const drawBorderBottom = (columnSizeIndex, parts) => {
  84. return drawBorder(columnSizeIndex, {
  85. body: parts.bottomBody,
  86. join: parts.bottomJoin,
  87. left: parts.bottomLeft,
  88. right: parts.bottomRight
  89. });
  90. };
  91. exports.drawBorderBottom = drawBorderBottom;
  92. //# sourceMappingURL=drawBorder.js.map