Skip to content

Commit 69b3813

Browse files
committed
feat: 🎸 unify PrintChild type and re-export everything
1 parent e099a69 commit 69b3813

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type * from './types';
2+
export * from './printTree';
3+
export * from './printBinary';

src/printBinary.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
type Child = (tab: string) => string;
1+
import type {PrintChild} from './types';
22

3-
export const printBinary = (tab = '', children: [left?: null | Child, right?: null | Child]): string => {
4-
const left = children[0], right = children[1];
3+
export const printBinary = (tab = '', children: [left?: null | PrintChild, right?: null | PrintChild]): string => {
4+
const left = children[0],
5+
right = children[1];
56
let str = '';
67
if (left) str += '\n' + tab + '← ' + left(tab + ' ');
78
if (right) str += '\n' + tab + '→ ' + right(tab + ' ');

src/printTree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
type Child = (tab: string) => string;
1+
import type {PrintChild} from './types';
22

3-
export const printTree = (tab = '', children: (Child | null)[]): string => {
3+
export const printTree = (tab = '', children: (PrintChild | null)[]): string => {
44
let str = '';
55
const length = children.length;
66
const last = length - 1;

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ export interface Printable {
1111
*/
1212
toString(tab?: string): string;
1313
}
14+
15+
export type PrintChild = (tab: string) => string;

0 commit comments

Comments
 (0)