Skip to content

Commit 80bd8da

Browse files
committed
Update printNode.js utility
- Add spacing after arrows
1 parent dde343a commit 80bd8da

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

data-structures/linked-lists/printNode.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Print node data to console
22

33
// Usage:
4-
// printNode('MY NODE', node, 'c') => MY NODE A→B→C→D→n
4+
// printNode('MY NODE', node, 'c') => MY NODE A→ B→ C→ D→ n
55
// printNode('POINT', curr, '☞', prev, 'h') => POINT C ☞ B
66
//
77
// h-rules (add padding to stretch):
@@ -109,22 +109,22 @@ function printNode () {
109109
// option: color
110110
case optsOb.c:
111111
if (firstItemFlag) { // style first item
112-
res += `${SGR.bold}${node.data}${SGR.reset}${SGR.dim}${SGR.reset}`;
112+
res += `${SGR.bold}${node.data}${SGR.reset}${SGR.dim} ${SGR.reset}`;
113113
} else { // style following items
114-
res += `${SGR.dim}${node.data}${SGR.reset}`
114+
res += `${SGR.dim}${node.data} ${SGR.reset}`
115115
}
116116
if (!node.next) res += `${SGR.red}n${padding}${SGR.reset}`; // append null
117117
break;
118118

119119
// option: dim
120120
case optsOb.d:
121-
res += `${SGR.dim}${node.data}${SGR.reset}`
121+
res += `${SGR.dim}${node.data} ${SGR.reset}`
122122
if (!node.next) res += `${SGR.dim}n${padding}${SGR.reset}` // append null
123123
break;
124124

125125
// option: none (default)
126126
default:
127-
res += node.data + '→';
127+
res += node.data + '→ ';
128128
if (!node.next) res += `n${padding}`;
129129
}
130130
firstItemFlag = false;
@@ -159,7 +159,7 @@ function printNode () {
159159

160160
if (arguments[arg] === 'i') {
161161
res +=
162-
`${'─'.repeat(process.env.COLUMNS - 3 || 80)}${SGR.dim}${count}${SGR.reset}`;
162+
`${'─'.repeat(process.env.COLUMNS - 3 || 80)}${SGR.dim} ${count}${SGR.reset}`;
163163
count++;
164164
}
165165

@@ -180,4 +180,5 @@ function printNode () {
180180
}
181181

182182
export default printNode;
183+
// @tjupp
183184

0 commit comments

Comments
 (0)