{"name":"unist-util-position","version":"5.0.0","description":"unist utility to get the position of a node","license":"MIT","keywords":["unist","unist-util","util","utility","node","position","point"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/unist-util-position.git"},"bugs":{"url":"https://github.com/syntax-tree/unist-util-position/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"}],"sideEffects":false,"type":"module","exports":"./index.js","dependencies":{"@types/unist":"^3.0.0"},"devDependencies":{"@types/node":"^20.0.0","c8":"^8.0.0","prettier":"^2.0.0","remark-cli":"^11.0.0","remark-preset-wooorm":"^9.0.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^0.54.0"},"scripts":{"prepack":"npm run build && npm run format","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark . -qfo && prettier . -w --loglevel 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,"ignoreCatch":true,"strict":true},"xo":{"prettier":true},"gitHead":"f7e6a973448608b0b9b20fdbc48a7b32f7630644","types":"./index.d.ts","homepage":"https://github.com/syntax-tree/unist-util-position#readme","_id":"unist-util-position@5.0.0","_nodeVersion":"20.0.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==","shasum":"678f20ab5ca1207a97d7ea8a388373c9cf896be4","tarball":"http://registry-npm.ywwl.com/unist-util-position/download/unist-util-position-5.0.0.tgz","fileCount":7,"unpackedSize":12779,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCE7Xsw+SHettM6uvdmbbaPNSZwXiQw8fEXGOsCf76+cAIhALTs1RRK73qxRLNZCg32p0as+3kL5oHllQYBuBnJ8dRw"}],"size":4369,"noattachment":false,"key":"/unist-util-position/-/unist-util-position-5.0.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","tmp":"tmp/unist-util-position_5.0.0_1688723974141_0.42545856751691313"},"_hasShrinkwrap":false,"readme":"# unist-util-position\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[unist][] utility to get positional info of nodes.\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    *   [`position(node)`](#positionnode)\n    *   [`pointEnd(node)`](#pointendnode)\n    *   [`pointStart(node)`](#pointstartnode)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis utility helps with accessing positional info on a potentially dirty tree.\n\n## When should I use this?\n\nThe positional info is typically consistent and proper in unist trees generated\nby our ecosystem, but, user plugins could mess that up.\nIf you’re making a reusable plugin, and accessing the positional info often, you\nmight want to guard against that by using this utility.\n\nYou might also find the utility [`unist-util-generated`][unist-util-generated]\nuseful to check whether a node is considered to be generated (not in the\noriginal input file).\n\nYou might also enjoy\n[`unist-util-stringify-position`][unist-util-stringify-position] when you want\nto display positional info to users.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install unist-util-position\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {pointEnd, pointStart, position} from 'https://esm.sh/unist-util-position@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {pointEnd, pointStart, position} from 'https://esm.sh/unist-util-position@5?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {fromMarkdown} from 'mdast-util-from-markdown'\nimport {pointEnd, pointStart, position} from 'unist-util-position'\n\nconst tree = fromMarkdown('# foo\\n\\n* bar\\n')\n\nconsole.log(position(tree))\nconsole.log(pointStart(tree))\nconsole.log(pointEnd(tree))\n```\n\nYields:\n\n```js\n{start: {line: 1, column: 1, offset: 0}, end: {line: 4, column: 1, offset: 13}}\n{line: 1, column: 1, offset: 0}\n{line: 4, column: 1, offset: 13}\n```\n\n## API\n\nThis package exports the identifiers [`pointEnd`][pointend],\n[`pointStart`][pointstart], and [`position`][position].\nThere is no default export.\n\n### `position(node)`\n\nGet the positional info of `node`.\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — node\n\n###### Returns\n\nPosition, if valid ([`Position`][unist-position] or `undefined`).\n\n### `pointEnd(node)`\n\nGet the ending point of `node`.\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — node\n\n###### Returns\n\nPoint, if valid ([`Point`][unist-point] or `undefined`).\n\n### `pointStart(node)`\n\nGet the starting point of `node`.\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — node\n\n###### Returns\n\nPoint, if valid ([`Point`][unist-point] or `undefined`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\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-position@^5`,\ncompatible with Node.js 16.\n\n## Related\n\n*   [`unist-util-stringify-position`](https://github.com/syntax-tree/unist-util-stringify-position)\n    — serialize a node, position, or point as a human readable location\n*   [`unist-util-position-from-estree`](https://github.com/syntax-tree/unist-util-position-from-estree)\n    — get a position from an estree node\n*   [`unist-util-remove-position`](https://github.com/syntax-tree/unist-util-remove-position)\n    — remove positions from tree\n*   [`unist-util-generated`](https://github.com/syntax-tree/unist-util-generated)\n    — check if a node is generated\n*   [`unist-util-source`](https://github.com/syntax-tree/unist-util-source)\n    — get the source of a node\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/syntax-tree/unist-util-position/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/unist-util-position/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-position.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/unist-util-position\n\n[downloads-badge]: https://img.shields.io/npm/dm/unist-util-position.svg\n\n[downloads]: https://www.npmjs.com/package/unist-util-position\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=unist-util-position\n\n[size]: https://bundlejs.com/?q=unist-util-position\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[unist]: https://github.com/syntax-tree/unist\n\n[node]: https://github.com/syntax-tree/unist#node\n\n[unist-position]: https://github.com/syntax-tree/unist#position\n\n[unist-point]: https://github.com/syntax-tree/unist#point\n\n[unist-util-generated]: https://github.com/syntax-tree/unist-util-generated\n\n[unist-util-stringify-position]: https://github.com/syntax-tree/unist-util-stringify-position\n\n[position]: #positionnode\n\n[pointend]: #pointendnode\n\n[pointstart]: #pointstartnode\n","publish_time":1688723974316,"_cnpm_publish_time":1688723974316,"dist-tags":{"latest":"5.0.0"}}