{"id":13527231,"url":"https://github.com/syntax-tree/unist-util-position","last_synced_at":"2025-06-29T22:03:39.339Z","repository":{"id":34584872,"uuid":"38531813","full_name":"syntax-tree/unist-util-position","owner":"syntax-tree","description":"utility to get the position of a node","archived":false,"fork":false,"pushed_at":"2023-07-07T09:59:32.000Z","size":120,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-05T01:27:49.254Z","etag":null,"topics":["location","position","syntax-tree","unist","unist-util","util","utility"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"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},"funding":{"github":"unifiedjs","open_collective":"unified"}},"created_at":"2015-07-04T11:31:18.000Z","updated_at":"2023-01-03T02:10:07.000Z","dependencies_parsed_at":"2024-06-03T17:11:42.333Z","dependency_job_id":null,"html_url":"https://github.com/syntax-tree/unist-util-position","commit_stats":{"total_commits":125,"total_committers":4,"mean_commits":31.25,"dds":0.03200000000000003,"last_synced_commit":"d086c6cf50f1206d47bbf8eff4411ec47a771165"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/unist-util-position","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-position","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-position/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-position/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-position/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/unist-util-position/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-position/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260050394,"owners_count":22951454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["location","position","syntax-tree","unist","unist-util","util","utility"],"created_at":"2024-08-01T06:01:43.708Z","updated_at":"2025-06-29T22:03:39.313Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","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\u003cscript type=\"module\"\u003e\n  import {pointEnd, pointStart, position} from 'https://esm.sh/unist-util-position@5?bundle'\n\u003c/script\u003e\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\u003c!-- Definitions --\u003e\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\u0026query=$.size.compressedSize\u0026url=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","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-util-position","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Funist-util-position","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-util-position/lists"}