{"id":13339448,"url":"https://github.com/flex-development/unist-util-inspect","last_synced_at":"2026-02-16T13:31:30.387Z","repository":{"id":246723322,"uuid":"821742767","full_name":"flex-development/unist-util-inspect","owner":"flex-development","description":"unist utility to inspect nodes","archived":false,"fork":false,"pushed_at":"2026-02-11T18:49:29.000Z","size":4013,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-12T03:05:37.831Z","etag":null,"topics":["console","inspect","syntax-tree","unist","unist-util"],"latest_commit_sha":null,"homepage":"https://github.com/flex-development/unist-util-inspect","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flex-development.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["flex-development"]}},"created_at":"2024-06-29T10:01:43.000Z","updated_at":"2026-02-11T18:47:10.000Z","dependencies_parsed_at":"2024-07-22T22:33:13.642Z","dependency_job_id":"88f35434-a6c6-4f1a-9063-1d62ac2ee4f4","html_url":"https://github.com/flex-development/unist-util-inspect","commit_stats":{"total_commits":181,"total_committers":3,"mean_commits":"60.333333333333336","dds":0.04972375690607733,"last_synced_commit":"fd08f2773b1e2523881dc0aeb07144a86f2068a9"},"previous_names":["flex-development/unist-util-inspect"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/flex-development/unist-util-inspect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Funist-util-inspect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Funist-util-inspect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Funist-util-inspect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Funist-util-inspect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flex-development","download_url":"https://codeload.github.com/flex-development/unist-util-inspect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Funist-util-inspect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29509091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","inspect","syntax-tree","unist","unist-util"],"created_at":"2024-07-29T19:20:03.419Z","updated_at":"2026-02-16T13:31:30.382Z","avatar_url":"https://github.com/flex-development.png","language":"TypeScript","funding_links":["https://github.com/sponsors/flex-development"],"categories":[],"sub_categories":[],"readme":"# unist-util-inspect\n\n[![ci](https://github.com/flex-development/unist-util-inspect/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/flex-development/unist-util-inspect/actions/workflows/ci.yml)\n[![github release](https://img.shields.io/github/v/release/flex-development/unist-util-inspect.svg?include_prereleases\\\u0026sort=semver)](https://github.com/flex-development/unist-util-inspect/releases/latest)\n[![npm](https://img.shields.io/npm/v/@flex-development/unist-util-inspect.svg)](https://npmjs.com/package/@flex-development/unist-util-inspect)\n[![npm downloads](https://img.shields.io/npm/dm/@flex-development/unist-util-inspect.svg)](https://www.npmcharts.com/compare/@flex-development/unist-util-inspect?interval=30)\n[![install size](https://packagephobia.now.sh/badge?p=@flex-development/unist-util-inspect)](https://packagephobia.now.sh/result?p=@flex-development/unist-util-inspect)\n[![codecov](https://codecov.io/gh/flex-development/unist-util-inspect/graph/badge.svg?token=4mBj091twh)](https://codecov.io/gh/flex-development/unist-util-inspect)\n[![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![license](https://img.shields.io/github/license/flex-development/unist-util-inspect.svg)](LICENSE.md)\n[![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits\\\u0026logoColor=ffffff)](https://conventionalcommits.org/)\n[![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript\\\u0026logoColor=ffffff)](https://typescriptlang.org/)\n[![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat\\\u0026logo=vitest\\\u0026logoColor=ffffff)](https://vitest.dev/)\n[![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat\\\u0026logo=yarn\\\u0026logoColor=ffffff)](https://yarnpkg.com/)\n\n[unist][] utility to inspect trees\n\n## Contents\n\n- [What is this?](#what-is-this)\n- [When should I use this?](#when-should-i-use-this)\n- [Install](#install)\n- [Use](#use)\n- [API](#api)\n  - [`inspect(tree[, options])`](#inspecttree-options)\n  - [`inspectColor(tree[, options])`](#inspectcolortree-options)\n  - [`inspectNoColor(tree[, options])`](#inspectnocolortree-options)\n- [Types](#types)\n  - [`Inspect`](#inspect)\n  - [`Options`](#options)\n- [Contribute](#contribute)\n\n## What is this?\n\nThis is a tiny, but useful, package that pretty prints any [unist][] [*tree*][tree].\n\n## When should I use this?\n\nThis utility pretty prints the tree in a format custom made for unist trees.\nThis is useful for spotting bugs, as well as getting an idea of whats going on in the tree.\nBoth trees and node lists can be printed.\n\n## Install\n\nThis package is [ESM only][esm].\n\nIn Node.js (18+) with [yarn][]:\n\n```sh\nyarn add @flex-development/unist-util-inspect\n```\n\n\u003cblockquote\u003e\n  \u003csmall\u003e\n    See \u003ca href='https://yarnpkg.com/protocol/git'\u003eGit - Protocols | Yarn\u003c/a\u003e\n    \u0026nbsp;for info regarding installing from Git.\n  \u003c/small\u003e\n\u003c/blockquote\u003e\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```ts\nimport { inspect } from 'https://esm.sh/@flex-development/unist-util-inspect'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { inspect } from 'https://esm.sh/@flex-development/unist-util-inspect'\n\u003c/script\u003e\n```\n\nWith [bun][]:\n\n```sh\nbun add @flex-development/unist-util-inspect\n```\n\n## Use\n\nSuppose we have the file [`dbl-linear.mts`](./dbl-linear.mts), and the following module, [`example.mts`](./example.mts):\n\n```ts\nimport type * as docast from '@flex-development/docast'\nimport { fromDocs } from '@flex-development/docast-util-from-docs'\nimport { inspect } from '@flex-development/unist-util-inspect'\nimport { read } from 'to-vfile'\nimport type { VFile } from 'vfile'\n\nconst file: VFile = await read('dbl-linear.mts')\n\nconst tree: docast.Root = fromDocs(file)\n\nconsole.log(inspect(tree))\n```\n\n...running `node --experimental-strip-types --experimental-transform-types ./example.mts` yields:\n\n```sh\nroot[7]\n├─0 comment[3] (1:1-5:4, 0-106)\n│   ├─0 blockTag\u003c@file\u003e[1] (2:4-2:19, 7-22)\n│   │   └─0 text \"dblLinear\" (2:10-2:19, 13-22)\n│   ├─1 blockTag\u003c@module\u003e[1] (3:4-3:21, 26-43)\n│   │   └─0 text \"dblLinear\" (3:12-3:21, 34-43)\n│   └─2 blockTag\u003c@see\u003e[1] (4:4-4:59, 47-102)\n│       └─0 text \"https://codewars.com/kata/5672682212c8ecf83e000050\" (4:9-4:59, 52-102)\n├─1 comment[7] (7:1-27:4, 108-684)\n│   ├─0 description[7] (8:4-14:68, 115-416)\n│   │   ├─0 paragraph[5] (8:4-8:60, 115-171)\n│   │   │   ├─0 text \"Consider a sequence \" (8:4-8:24, 115-135)\n│   │   │   ├─1 inlineCode \"u\" (8:24-8:27, 135-138)\n│   │   │   ├─2 text \" where \" (8:27-8:34, 138-145)\n│   │   │   ├─3 inlineCode \"u\" (8:34-8:37, 145-148)\n│   │   │   └─4 text \" is defined as follows:\" (8:37-8:60, 148-171)\n│   │   ├─1 break (8:60-9:1, 171-172)\n│   │   ├─2 break (9:3-10:1, 174-175)\n│   │   │     data: {\"blank\":true}\n│   │   ├─3 list[3] (1:1-1:1)\n│   │   │   │ ordered: true\n│   │   │   │ start: 1\n│   │   │   │ spread: false\n│   │   │   ├─0 listItem[4] (10:5-10:53, 179-227)\n│   │   │   │   │ spread: false\n│   │   │   │   │ checked: null\n│   │   │   │   ├─0 text \"The number \" (10:8-10:19, 182-193)\n│   │   │   │   ├─1 inlineCode \"u(0) = 1\" (10:19-10:29, 193-203)\n│   │   │   │   ├─2 text \" is the first one in \" (10:29-10:50, 203-224)\n│   │   │   │   └─3 inlineCode \"u\" (10:50-10:53, 224-227)\n│   │   │   ├─1 listItem[11] (11:5-11:77, 232-304)\n│   │   │   │   │ spread: false\n│   │   │   │   │ checked: null\n│   │   │   │   ├─0  text \"For each \" (11:8-11:17, 235-244)\n│   │   │   │   ├─1  inlineCode \"x\" (11:17-11:20, 244-247)\n│   │   │   │   ├─2  text \" in \" (11:20-11:24, 247-251)\n│   │   │   │   ├─3  inlineCode \"u\" (11:24-11:27, 251-254)\n│   │   │   │   ├─4  text \", \" (11:27-11:29, 254-256)\n│   │   │   │   ├─5  inlineCode \"y = 2x + 1\" (11:29-11:41, 256-268)\n│   │   │   │   ├─6  text \" and \" (11:41-11:46, 268-273)\n│   │   │   │   ├─7  inlineCode \"z = 3x + 1\" (11:46-11:58, 273-285)\n│   │   │   │   ├─8  text \" must be in \" (11:58-11:70, 285-297)\n│   │   │   │   ├─9  inlineCode \"u\" (11:70-11:73, 297-300)\n│   │   │   │   └─10 text \" too\" (11:73-11:77, 300-304)\n│   │   │   └─2 listItem[2] (12:5-12:41, 309-345)\n│   │   │       │ spread: false\n│   │   │       │ checked: null\n│   │   │       ├─0 text \"There are no other numbers in \" (12:8-12:38, 312-342)\n│   │   │       └─1 inlineCode \"u\" (12:38-12:41, 342-345)\n│   │   ├─4 break (12:41-13:1, 345-346)\n│   │   ├─5 break (13:3-14:1, 348-349)\n│   │   │     data: {\"blank\":true}\n│   │   └─6 paragraph[5] (14:4-14:68, 352-416)\n│   │       ├─0 text \"Given an index, \" (14:4-14:20, 352-368)\n│   │       ├─1 inlineCode \"n\" (14:20-14:23, 368-371)\n│   │       ├─2 text \", the function returns the element at \" (14:23-14:61, 371-409)\n│   │       ├─3 inlineCode \"u(n)\" (14:61-14:67, 409-415)\n│   │       └─4 text \".\" (14:67-14:68, 415-416)\n│   ├─1 blockTag\u003c@example\u003e[1] (16:4-17:28, 423-459)\n│   │   └─0 code \"await dblLinear(0) // 1\" (17:5-17:28, 436-459)\n│   │         lang: null\n│   │         meta: null\n│   ├─2 blockTag\u003c@example\u003e[1] (18:4-19:30, 463-501)\n│   │   └─0 code \"await dblLinear(10) // 22\" (19:5-19:30, 476-501)\n│   │         lang: null\n│   │         meta: null\n│   ├─3 blockTag\u003c@example\u003e[1] (20:4-21:32, 505-545)\n│   │   └─0 code \"await dblLinear(100) // 447\" (21:5-21:32, 518-545)\n│   │         lang: null\n│   │         meta: null\n│   ├─4 blockTag\u003c@example\u003e[1] (22:4-23:36, 549-593)\n│   │   └─0 code \"await dblLinear(7687) // 111718\" (23:5-23:36, 562-593)\n│   │         lang: null\n│   │         meta: null\n│   ├─5 blockTag\u003c@param\u003e[2] (25:4-25:46, 600-642)\n│   │   ├─0 typeExpression \"number\" (25:11-25:19, 607-615)\n│   │   └─1 text \"n - Sequence element index\" (25:20-25:46, 616-642)\n│   └─6 blockTag\u003c@return\u003e[3] (26:4-26:38, 646-680)\n│       ├─0 typeExpression \"number\" (26:12-26:20, 654-662)\n│       ├─1 text \"Element at \" (26:21-26:32, 663-674)\n│       └─2 inlineCode \"u(n)\" (26:32-26:38, 674-680)\n├─2 comment[2] (29:3-33:6, 727-781)\n│   ├─0 description[1] (30:6-30:15, 736-745)\n│   │   └─0 paragraph[1] (30:6-30:15, 736-745)\n│   │       └─0 text \"Sequence.\" (30:6-30:15, 736-745)\n│   └─1 blockTag\u003c@const\u003e[2] (32:6-33:1, 756-776)\n│       ├─0 typeExpression \"number[]\" (32:13-32:23, 763-773)\n│       └─1 text \"u\" (32:24-32:25, 774-775)\n├─3 comment[2] (36:3-40:6, 811-900)\n│   ├─0 description[1] (37:6-37:54, 820-868)\n│   │   └─0 paragraph[3] (37:6-37:54, 820-868)\n│   │       ├─0 text \"Index of x in \" (37:6-37:20, 820-834)\n│   │       ├─1 inlineTag\u003c@linkcode\u003e \"u\" (37:20-37:33, 834-847)\n│   │       └─2 text \" used to calculate y.\" (37:33-37:54, 847-868)\n│   └─1 blockTag\u003c@var\u003e[2] (39:6-40:1, 879-895)\n│       ├─0 typeExpression \"number\" (39:11-39:19, 884-892)\n│       └─1 text \"j\" (39:20-39:21, 893-894)\n├─4 comment[2] (43:3-47:6, 924-1013)\n│   ├─0 description[1] (44:6-44:54, 933-981)\n│   │   └─0 paragraph[3] (44:6-44:54, 933-981)\n│   │       ├─0 text \"Index of x in \" (44:6-44:20, 933-947)\n│   │       ├─1 inlineTag\u003c@linkcode\u003e \"u\" (44:20-44:33, 947-960)\n│   │       └─2 text \" used to calculate z.\" (44:33-44:54, 960-981)\n│   └─1 blockTag\u003c@var\u003e[2] (46:6-47:1, 992-1008)\n│       ├─0 typeExpression \"number\" (46:11-46:19, 997-1005)\n│       └─1 text \"j\" (46:20-46:21, 1006-1007)\n├─5 comment[2] (52:5-56:8, 1118-1173)\n│   ├─0 description[1] (53:8-53:12, 1129-1133)\n│   │   └─0 paragraph[2] (53:8-53:12, 1129-1133)\n│   │       ├─0 inlineCode \"y\" (53:8-53:11, 1129-1132)\n│   │       └─1 text \".\" (53:11-53:12, 1132-1133)\n│   └─1 blockTag\u003c@const\u003e[2] (55:8-56:1, 1148-1166)\n│       ├─0 typeExpression \"number\" (55:15-55:23, 1155-1163)\n│       └─1 text \"y\" (55:24-55:25, 1164-1165)\n└─6 comment[2] (59:5-63:8, 1215-1270)\n    ├─0 description[1] (60:8-60:12, 1226-1230)\n    │   └─0 paragraph[2] (60:8-60:12, 1226-1230)\n    │       ├─0 inlineCode \"z\" (60:8-60:11, 1226-1229)\n    │       └─1 text \".\" (60:11-60:12, 1229-1230)\n    └─1 blockTag\u003c@const\u003e[2] (62:8-63:1, 1245-1263)\n        ├─0 typeExpression \"number\" (62:15-62:23, 1252-1260)\n        └─1 text \"z\" (62:24-62:25, 1261-1262)\n```\n\n## API\n\nThis package exports the identifiers\n[`inspect`](#inspecttree-options),\n[`inspectColor`](#inspectcolortree-options),\nand [`inspectNoColor`](#inspectnocolortree-options).\n\nThere is no default export.\n\n### `inspect(tree[, options])`\n\nInspect a tree with color in supported environments or without color in environments that do not support color.\n\n#### Parameters\n\n- `tree` (`unknown`)\n  — the tree to inspect\n- `options` ([`Options`](#options) | `null` | `undefined`)\n  — configuration options\n\n#### Returns\n\n(`string`) Pretty printed `tree`\n\n### `inspectColor(tree[, options])`\n\nInspect a tree with color.\n\nOtherwise the same as [`inspect`](#inspecttree-options).\n\n### `inspectNoColor(tree[, options])`\n\nInspect a tree without color.\n\nOtherwise the same as [`inspect`](#inspecttree-options).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\n\n### `Inspect`\n\nInspect a tree (TypeScript type).\n\n```ts\ntype Inspect = (tree: unknown, options?: Options | null | undefined) =\u003e string\n```\n\n#### Parameters\n\n- `tree` (`unknown`)\n  — the tree to inspect\n- `options` ([`Options`](#options) | `null` | `undefined`)\n  — configuration options\n\n#### Returns\n\n(`string`) Pretty printed `tree`\n\n### `Options`\n\nConfiguration options (TypeScript interface).\n\n#### Properties\n\n- `positions?` (`boolean | null | undefined`)\n  — whether to include positional information\n  - **default**: `true`\n\n## Contribute\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md).\n\nThis project has a [code of conduct](CODE_OF_CONDUCT.md). By interacting with this repository, organization, or\ncommunity you agree to abide by its terms.\n\n[bun]: https://bun.sh\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[tree]: https://github.com/syntax-tree/unist#tree\n\n[typescript]: https://www.typescriptlang.org\n\n[unist]: https://github.com/syntax-tree/unist\n\n[yarn]: https://yarnpkg.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Funist-util-inspect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflex-development%2Funist-util-inspect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Funist-util-inspect/lists"}