console-log-tree
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/console-log-tree package

1.2.1 • Public • Published

console-log-tree

Log the tree of an array or object

Example

Input

[
  {
    "name": "photos",
    "children": [
      {
        "name": "summer",
        "children": [
          {
            "name": "june",
            "children": [
              {
                "name": "windsurf.jpg",
              }
            ]
          }
        ]
      },
      {
        "name": "winter",
        "children": [
          {
            "name": "january",
            "children": [
              {
                "name": "ski.png",
              },
              {
                "name": "snowboard.jpg",
              }
            ]
          }
        ]
      }
    ]
  },
  {
    "name":'doc'
  }
]

Output

├── photos
│   ├── summer
│   │   └── june
│   │       └── windsurf.jpg
│   └── winter
│       └── january
│           ├── ski.png
│           └── snowboard.jpg
└── doc

Use

npm install console-log-tree
const logTree = require('console-log-tree')
 
const tree = {...}
 
const treeStr = logTree.parse(tree)
 
console.log(treeStr)
 
// OR
 
logTree.log(tree)

Readme

Keywords

none

Package Sidebar

Install

npm i console-log-tree

Weekly Downloads

1,411

Version

1.2.1

License

ISC

Unpacked Size

13.5 kB

Total Files

8

Last publish

Collaborators

  • qishaoxuan