Ohm-Management - Projektarbeit B-ME
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.

drawBorder.js.flow 1.9KB

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