unist-util-inspect

Build Coverage Downloads Size Sponsors Backers Chat

unist utility to inspect nodes.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install unist-util-inspect

Use

import {u} from 'unist-builder'
import {inspect} from 'unist-util-inspect'

const 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]
ā”œā”€0 literal "1"
ā””ā”€1 parent[3]
    ā”œā”€0 void
    ā”‚     id: "a"
    ā”œā”€1 literal "2"
    ā””ā”€2 node[0]
          id: "b"

API

This package exports the following identifiers: inspect, inspectColor, and inspectNoColor. There is no default export.

inspect(node[, options])

Inspect the given node. By default, colors are added in Node, and not in other places. See below on how to change that.

options.showPositions

Whether to include positional information (boolean, default: true).

Returns

string ā€” String representing node.

inspectColor(node[, options])

Inspect, with ANSI color sequences (default in Node).

inspectNoColor(node[, options])

Inspect, but without ANSI color sequences (default in browser).

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

Unist Util Inspect

utility to inspect nodes

Unist Util Inspect Info

ā­ Stars 16
šŸ”— Homepage unifiedjs.com
šŸ”— Source Code github.com
šŸ•’ Last Update a year ago
šŸ•’ Created 8 years ago
šŸž Open Issues 0
āž— Star-Issue Ratio Infinity
šŸ˜Ž Author syntax-tree