Skip to content

Commit e099a69

Browse files
committed
feat: 🎸 improve printBinary() performance
1 parent 5cf10dd commit e099a69

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/printBinary.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
type Child = (tab: string) => string;
22

33
export const printBinary = (tab = '', children: [left?: null | Child, right?: null | Child]): string => {
4-
const [left, right] = children;
4+
const left = children[0], right = children[1];
55
let str = '';
6-
if (left) str += `\n${tab}${left(tab + ' ')}`;
7-
if (right) str += `\n${tab}${right(tab + ' ')}`;
6+
if (left) str += '\n' + tab + '← ' + left(tab + ' ');
7+
if (right) str += '\n' + tab + '→ ' + right(tab + ' ');
88
return str;
99
};

0 commit comments

Comments
 (0)