{"id":13339497,"url":"https://github.com/syntax-tree/unist-util-stringify-position","last_synced_at":"2025-06-29T22:03:41.789Z","repository":{"id":57386389,"uuid":"56377330","full_name":"syntax-tree/unist-util-stringify-position","owner":"syntax-tree","description":"utility to serialize a node, position, or point as a human readable location","archived":false,"fork":false,"pushed_at":"2023-07-07T10:09:24.000Z","size":109,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-16T03:52:41.238Z","etag":null,"topics":["position","stringify","syntax-tree","unist","unist-util","util"],"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":"2016-04-16T10:10:03.000Z","updated_at":"2024-02-01T22:03:09.000Z","dependencies_parsed_at":"2024-06-18T16:57:47.403Z","dependency_job_id":null,"html_url":"https://github.com/syntax-tree/unist-util-stringify-position","commit_stats":{"total_commits":100,"total_committers":3,"mean_commits":"33.333333333333336","dds":"0.040000000000000036","last_synced_commit":"be908410e4acaca52ea5a723ca7c558fdb269cab"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/unist-util-stringify-position","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-stringify-position","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-stringify-position/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-stringify-position/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-stringify-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-stringify-position/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-stringify-position/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262188185,"owners_count":23272323,"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":["position","stringify","syntax-tree","unist","unist-util","util"],"created_at":"2024-07-29T19:20:04.177Z","updated_at":"2025-06-29T22:03:41.747Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# unist-util-stringify-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 pretty print the positional info of a node.\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    *   [`stringifyPosition(node|position|point)`](#stringifypositionnodepositionpoint)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a utility that takes any [unist][] (whether mdast, hast, etc)\nnode, position, or point, and serializes its positional info.\n\n## When should I use this?\n\nThis utility is useful to display where something occurred in the original\ndocument, in one standard way, for humans.\nFor example, when throwing errors or warning messages about something.\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-stringify-position\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {stringifyPosition} from 'https://esm.sh/unist-util-stringify-position@4'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {stringifyPosition} from 'https://esm.sh/unist-util-stringify-position@4?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {stringifyPosition} from 'unist-util-stringify-position'\n\nstringifyPosition({line: 2, column: 3}) // =\u003e '2:3' (point)\nstringifyPosition({start: {line: 2}, end: {line: 3}}) // =\u003e '2:1-3:1' (position)\nstringifyPosition({\n  type: 'text',\n  value: '!',\n  position: {\n    start: {line: 5, column: 11},\n    end: {line: 5, column: 12}\n  }\n}) // =\u003e '5:11-5:12' (node)\n```\n\n## API\n\nThis package exports the identifier [`stringifyPosition`][stringifyposition].\nThere is no default export.\n\n### `stringifyPosition(node|position|point)`\n\nSerialize the positional info of a point, position (start and end points), or\nnode.\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — node whose `position` fields to serialize\n*   `position` ([`Position`][position])\n    — position whose `start` and `end` points to serialize\n*   `point` ([`Point`][point])\n    — point whose `line` and `column` fields to serialize\n\n###### Returns\n\nPretty printed positional info of a node (`string`).\n\nIn the format of a range `ls:cs-le:ce` (when given `node` or `position`) or a\npoint `l:c` (when given `point`), where `l` stands for line, `c` for column, `s`\nfor `start`, and `e` for end.\nAn empty string (`''`) is returned if the given value is neither `node`,\n`position`, nor `point`.\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,\n`unist-util-stringify-position@^4`, compatible with Node.js 16.\n\n## Security\n\nThis project is safe.\n\n## Related\n\n*   [`unist-util-generated`](https://github.com/syntax-tree/unist-util-generated)\n    — check if a node is generated\n*   [`unist-util-position`](https://github.com/syntax-tree/unist-util-position)\n    — get positional info of nodes\n*   [`unist-util-remove-position`](https://github.com/syntax-tree/unist-util-remove-position)\n    — remove positional info from trees\n*   [`unist-util-source`](https://github.com/syntax-tree/unist-util-source)\n    — get the source of a value (node or position) in a file\n\n## Contribute\n\nSee [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get\nstarted.\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!-- Definition --\u003e\n\n[build-badge]: https://github.com/syntax-tree/unist-util-stringify-position/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/unist-util-stringify-position/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-stringify-position.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/unist-util-stringify-position\n\n[downloads-badge]: https://img.shields.io/npm/dm/unist-util-stringify-position.svg\n\n[downloads]: https://www.npmjs.com/package/unist-util-stringify-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-stringify-position\n\n[size]: https://bundlejs.com/?q=unist-util-stringify-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[license]: license\n\n[author]: https://wooorm.com\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\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[position]: https://github.com/syntax-tree/unist#position\n\n[point]: https://github.com/syntax-tree/unist#point\n\n[stringifyposition]: #stringifypositionnodepositionpoint\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-util-stringify-position","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Funist-util-stringify-position","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-util-stringify-position/lists"}