deep-print
v1.0.1
Published
Displays a tree structure in the console, supporting both binary trees and trees with an arbitrary number of children.
Downloads
6
Readme
deep-print
Displays a tree structure in the console, supporting both binary trees and trees with an arbitrary number of children.
Installation
To install the package, use npm:
pnpm add deep-print
yarn install deep-print
npm install deep-print
Usage
// Deep Print
import React from "react";
import { dp } from "deep-print";
const str = 'start' + dp('', [
(tab) => 'line 1',
(tab) => 'line 2' + dp(tab, [
(tab) => 'line 2.1',
(tab) => 'line 2.2',
])
(tab) => 'line 3',
]);
console.log(str);
// start
// ├── line 1
// │
// ├── line 2
// │ ├── line 2.1
// │ └── line 2.2
// └── line 3
// Deep Print Binary
import React from "react";
import { dpd } from "deep-print";
const str =
"Node" +
dpd("", [
(tab) => "left" + printBinary(tab, [() => "left 1", () => "right 1"]),
(tab) => "right" + printBinary(tab, [() => "left 2", () => "right 2"]),
]);
console.log(str);
// Node
// ← left
// ← left 1
// → right 1
// → right
// ← left 2
// → right 2
tsup
Bundle your TypeScript library with no config, powered by esbuild.
https://tsup.egoist.dev/
How to use this
- install dependencies
# pnpm
$ pnpm install
# yarn
$ yarn install
# npm
$ npm install
- Add your code to
src
- Add export statement to
src/index.ts
- Test build command to build
src
. Once the command works properly, you will seedist
folder.
# pnpm
$ pnpm run build
# yarn
$ yarn run build
# npm
$ npm run build
- Publish your package
$ npm publish
test package
https://www.npmjs.com/package/deep-print