forked from OSSPhilippines/covid19-tracker-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetBoxArt.ts
More file actions
44 lines (39 loc) · 1.21 KB
/
getBoxArt.ts
File metadata and controls
44 lines (39 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import colors from "colors";
const regularBoxArt = {
topLeft: "╔",
topRight: "╗",
bottomLeft: "╚",
bottomRight: "╝",
vertical: "║",
horizontal: "═",
verticallyMergeRight: "╠",
verticallyMergeLeft: "╣",
horizontallyMergeUp: "╩",
horizontallyMergeDown: "╦",
horizontallyMergeSingleUp: "╧",
intersection: "╬",
singleVertical: "│",
singleHorizontal: "─",
singleIntersection: "┼",
singleVerticallyMergeRight: "╟",
singleVerticallyMergeLeft: "╢",
singleHorizontallyMergeUp: "╧",
singleHorizontallyMergeDown: "╤",
};
export type BoxArt = typeof regularBoxArt;
/**
*
* @param color is a string that can be used by the colors library to color-ify strings
* @returns An object containing colored box art pieces
*/
export const getBoxArt: (color: keyof colors.Color) => BoxArt = (color) => {
let keys = Object.keys(regularBoxArt) as unknown as (keyof BoxArt)[];
let coloredPieces = Object.values(regularBoxArt).map((piece) => {
return colors[color](piece);
});
let response = {} as BoxArt;
keys.forEach((key, index) => {
response[key] = coloredPieces[index];
});
return response;
};