{"name":"unist-util-visit","version":"5.1.0","description":"unist utility to visit nodes","license":"MIT","keywords":["unist","unist-util","util","utility","remark","retext","rehype","mdast","hast","xast","nlcst","natural","language","markdown","html","xml","tree","ast","node","visit","walk"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/unist-util-visit.git"},"bugs":{"url":"https://github.com/syntax-tree/unist-util-visit/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},{"name":"Eugene Sharygin","email":"eush77@gmail.com"},{"name":"Richard Gibson","email":"richard.gibson@gmail.com"}],"sideEffects":false,"type":"module","exports":"./index.js","dependencies":{"@types/unist":"^3.0.0","unist-util-is":"^6.0.0","unist-util-visit-parents":"^6.0.0"},"devDependencies":{"@types/mdast":"^4.0.0","@types/node":"^25.0.0","c8":"^10.0.0","mdast-util-from-markdown":"^2.0.0","mdast-util-gfm":"^3.0.0","micromark-extension-gfm":"^3.0.0","prettier":"^3.0.0","remark-cli":"^12.0.0","remark-preset-wooorm":"^11.0.0","tsd":"^0.33.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^1.0.0"},"scripts":{"prepack":"npm run build && npm run format","build":"tsc --build --clean && tsc --build && tsd && type-coverage","format":"remark . -qfo && prettier . -w --log-level warn && xo --fix","test-api":"node --conditions development test.js","test-coverage":"c8 --100 --reporter lcov npm run test-api","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"bracketSpacing":false,"semi":false,"singleQuote":true,"tabWidth":2,"trailingComma":"none","useTabs":false},"remarkConfig":{"plugins":["remark-preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"#":"needed `any`s","ignoreFiles":["lib/index.d.ts"],"ignoreCatch":true,"strict":true},"xo":{"space":true,"prettier":true,"rules":{"unicorn/prefer-at":"off"}},"gitHead":"5d601df684ca7341646d6b57eb0f20fdfe277bc2","types":"./index.d.ts","_id":"unist-util-visit@5.1.0","homepage":"https://github.com/syntax-tree/unist-util-visit#readme","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==","shasum":"9a2a28b0aa76a15e0da70a08a5863a2f060e2468","tarball":"http://registry-npm.ywwl.com/unist-util-visit/download/unist-util-visit-5.1.0.tgz","fileCount":8,"unpackedSize":33781,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDbWJn69mZTvOLq0Ouup3RiNWguioein0DVSylyhtN/EQIhAOEJalY4vvhgrjwCOqWqoCnj3oTnWuo+65Gw9kGS5mSS"}],"size":8762,"noattachment":false,"key":"/unist-util-visit/-/unist-util-visit-5.1.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unist-util-visit_5.1.0_1769108578838_0.5730214506860105"},"_hasShrinkwrap":false,"readme":"# unist-util-visit\n\n[![Build][badge-build-image]][badge-build-url]\n[![Coverage][badge-coverage-image]][badge-coverage-url]\n[![Downloads][badge-downloads-image]][badge-downloads-url]\n[![Size][badge-size-image]][badge-size-url]\n\n[unist][github-unist] utility to walk the tree.\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  * [`visit(tree[, test], visitor[, reverse])`](#visittree-test-visitor-reverse)\n  * [`CONTINUE`](#continue)\n  * [`EXIT`](#exit)\n  * [`SKIP`](#skip)\n  * [`Action`](#action)\n  * [`ActionTuple`](#actiontuple)\n  * [`BuildVisitor`](#buildvisitor)\n  * [`Index`](#index)\n  * [`Test`](#test)\n  * [`Visitor`](#visitor)\n  * [`VisitorResult`](#visitorresult)\n* [Compatibility](#compatibility)\n* [Related](#related)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis is a very important utility for working with unist as it lets you walk the\ntree.\n\n## When should I use this?\n\nYou can use this utility when you want to walk the tree.\nYou can use [`unist-util-visit-parents`][github-vp] if you care about the\nentire stack of parents.\n\n## Install\n\nThis package is [ESM only][github-gist-esm].\nIn Node.js (version 16+),\ninstall with [npm][npmjs-install]:\n\n```sh\nnpm install unist-util-visit\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {CONTINUE, EXIT, SKIP, visit} from 'https://esm.sh/unist-util-visit@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {CONTINUE, EXIT, SKIP, visit} from 'https://esm.sh/unist-util-visit@5?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {fromMarkdown} from 'mdast-util-from-markdown'\nimport {visit} from 'unist-util-visit'\n\nconst tree = fromMarkdown('Some *emphasis*, **strong**, and `code`.')\n\nvisit(tree, 'text', function (node, index, parent) {\n  console.log([node.value, parent ? parent.type : index])\n})\n```\n\nYields:\n\n```js\n[ 'Some ', 'paragraph' ]\n[ 'emphasis', 'emphasis' ]\n[ ', ', 'paragraph' ]\n[ 'strong', 'strong' ]\n[ ', and ', 'paragraph' ]\n[ '.', 'paragraph' ]\n```\n\n## API\n\nThis package exports the identifiers\n[`CONTINUE`][api-continue],\n[`EXIT`][api-exit],\n[`SKIP`][api-skip], and\n[`visit`][api-visit].\nIt exports the [TypeScript][] types\n[`ActionTuple`][api-action-tuple],\n[`Action`][api-action],\n[`BuildVisitor`][api-build-visitor],\n[`Index`][api-index],\n[`Test`][api-test],\n[`VisitorResult`][api-visitor-result], and\n[`Visitor`][api-visitor].\nThere is no default export.\n\n### `visit(tree[, test], visitor[, reverse])`\n\nThis function works exactly the same as\n[`unist-util-visit-parents`][github-vp],\nbut [`Visitor`][api-visitor] has a different signature.\n\n### `CONTINUE`\n\nContinue traversing as normal (`true`).\n\n### `EXIT`\n\nStop traversing immediately (`false`).\n\n### `SKIP`\n\nDo not traverse this node’s children (`'skip'`).\n\n### `Action`\n\nUnion of the action types (TypeScript type).\nSee [`Action` in `unist-util-visit-parents`][github-vp-action].\n\n### `ActionTuple`\n\nList with an action and an index (TypeScript type).\nSee [`ActionTuple` in `unist-util-visit-parents`][github-vp-action-tuple].\n\n### `BuildVisitor`\n\nBuild a typed `Visitor` function from a tree and a test (TypeScript type).\nSee [`BuildVisitor` in `unist-util-visit-parents`][github-vp-build-visitor].\n\n### `Index`\n\nMove to the sibling at `index` next (TypeScript type).\nSee [`Index` in `unist-util-visit-parents`][github-vp-index].\n\n### `Test`\n\n[`unist-util-is`][github-unist-util-is] compatible test\n(TypeScript type).\n\n### `Visitor`\n\nHandle a node (matching `test`, if given) (TypeScript type).\n\nVisitors are free to transform `node`.\nThey can also transform `parent`.\n\nReplacing `node` itself, if `SKIP` is not returned, still causes its\ndescendants to be walked (which is a bug).\n\nWhen adding or removing previous siblings of `node` (or next siblings, in\ncase of reverse), the `Visitor` should return a new `Index` to specify the\nsibling to traverse after `node` is traversed.\nAdding or removing next siblings of `node` (or previous siblings, in case\nof reverse) is handled as expected without needing to return a new `Index`.\n\nRemoving the children property of `parent` still results in them being\ntraversed.\n\n###### Parameters\n\n* `node` ([`Node`][github-unist-node])\n  — found node\n* `index` (`number` or `undefined`)\n  — index of `node` in `parent`\n* `parent` ([`Node`][github-unist-node] or `undefined`)\n  — parent of `node`\n\n###### Returns\n\nWhat to do next.\n\nAn `Index` is treated as a tuple of `[CONTINUE, Index]`.\nAn `Action` is treated as a tuple of `[Action]`.\n\nPassing a tuple back only makes sense if the `Action` is `SKIP`.\nWhen the `Action` is `EXIT`, that action can be returned.\nWhen the `Action` is `CONTINUE`, `Index` can be returned.\n\n### `VisitorResult`\n\nAny value that can be returned from a visitor (TypeScript type).\nSee [`VisitorResult` in\n`unist-util-visit-parents`][github-vp-visitor-result].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `unist-util-visit@^5`,\ncompatible with Node.js 16.\n\n## Related\n\n* [`unist-util-visit-parents`][github-vp]\n  — walk the tree with a stack of parents\n* [`unist-util-filter`](https://github.com/syntax-tree/unist-util-filter)\n  — create a new tree with all nodes that pass a test\n* [`unist-util-map`](https://github.com/syntax-tree/unist-util-map)\n  — create a new tree with all nodes mapped by a given function\n* [`unist-util-flatmap`](https://gitlab.com/staltz/unist-util-flatmap)\n  — create a new tree by mapping (to an array) with the given function\n* [`unist-util-remove`](https://github.com/syntax-tree/unist-util-remove)\n  — remove nodes from a tree that pass a test\n* [`unist-util-select`](https://github.com/syntax-tree/unist-util-select)\n  — select nodes with CSS-like selectors\n\n## Contribute\n\nSee [`contributing.md`][health-contributing] in [`syntax-tree/.github`][health]\nfor ways to get started.\nSee [`support.md`][health-support] for ways to get help.\n\nThis project has a [code of conduct][health-coc].\nBy interacting with this repository,\norganization,\nor community you agree to abide by its terms.\n\n## License\n\n[MIT][file-license] © [Titus Wormer][wooorm]\n\n<!-- Definition -->\n\n[api-action]: #action\n\n[api-action-tuple]: #actiontuple\n\n[api-build-visitor]: #buildvisitor\n\n[api-continue]: #continue\n\n[api-exit]: #exit\n\n[api-index]: #index\n\n[api-skip]: #skip\n\n[api-test]: #test\n\n[api-visit]: #visittree-test-visitor-reverse\n\n[api-visitor]: #visitor\n\n[api-visitor-result]: #visitorresult\n\n[badge-build-image]: https://github.com/syntax-tree/unist-util-visit/workflows/main/badge.svg\n\n[badge-build-url]: https://github.com/syntax-tree/unist-util-visit/actions\n\n[badge-coverage-image]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-visit.svg\n\n[badge-coverage-url]: https://codecov.io/github/syntax-tree/unist-util-visit\n\n[badge-downloads-image]: https://img.shields.io/npm/dm/unist-util-visit.svg\n\n[badge-downloads-url]: https://www.npmjs.com/package/unist-util-visit\n\n[badge-size-image]: https://img.shields.io/bundlejs/size/unist-util-visit\n\n[badge-size-url]: https://bundlejs.com/?q=unist-util-visit\n\n[esmsh]: https://esm.sh\n\n[file-license]: license\n\n[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[github-unist]: https://github.com/syntax-tree/unist\n\n[github-unist-node]: https://github.com/syntax-tree/unist#nodes\n\n[github-unist-util-is]: https://github.com/syntax-tree/unist-util-is\n\n[github-vp]: https://github.com/syntax-tree/unist-util-visit-parents\n\n[github-vp-action]: https://github.com/syntax-tree/unist-util-visit-parents#action\n\n[github-vp-action-tuple]: https://github.com/syntax-tree/unist-util-visit-parents#actiontuple\n\n[github-vp-build-visitor]: https://github.com/syntax-tree/unist-util-visit-parents#buildvisitor\n\n[github-vp-index]: https://github.com/syntax-tree/unist-util-visit-parents#index\n\n[github-vp-visitor-result]: https://github.com/syntax-tree/unist-util-visit-parents#visitorresult\n\n[health]: https://github.com/syntax-tree/.github\n\n[health-coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[health-contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[health-support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[npmjs-install]: https://docs.npmjs.com/cli/install\n\n[typescript]: https://www.typescriptlang.org\n\n[wooorm]: https://wooorm.com\n","publish_time":1769108578977,"_cnpm_publish_time":1769108578977,"dist-tags":{"latest":"5.2.0"}}