unist utility to inspect nodes


Keywords
unist, unist-util, util, utility, inspect, debug, log, console, syntax-tree
License
MIT
Install
npm install unist-util-inspect@5.0.1

Documentation

unist-util-inspect

Build Coverage Downloads Size Sponsors Backers Chat

unist utility to inspect nodes.

Install

npm:

npm install unist-util-inspect

Use

var u = require('unist-builder')
var inspect = require('unist-util-inspect')

var tree = u('root', [
  u('literal', '1'),
  u('parent', [
    u('void', {id: 'a'}),
    u('literal', '2'),
    u('node', {id: 'b'}, [])
  ])
])

console.log(inspect(tree))

Yields:

root[2]
├─ literal: "1"
└─ parent[3]
   ├─ void [id="a"]
   ├─ literal: "2"
   └─ node[0] [id="b"]

API

inspect(node)

By default, color support is enabled in Node.js and turned off anywhere else. See below on how to change that.

Parameters
Returns

string — String representing node.

inspect.<style>[.<style>…](node)

Where <style> is either color or noColor.

To explicitly add or remove ANSI sequences, use either inspect.color(node) or inspect.noColor(node).

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer