{"name":"vfile-location","version":"5.0.3","description":"vfile utility to convert between positional (line and column-based) and offset (range-based) locations","license":"MIT","keywords":["vfile","vfile-util","util","utility","virtual","file","location","point","position","offset"],"repository":{"type":"git","url":"git+https://github.com/vfile/vfile-location.git"},"bugs":{"url":"https://github.com/vfile/vfile-location/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":"Christian Murphy","email":"christian.murphy.42@gmail.com"}],"sideEffects":false,"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"dependencies":{"@types/unist":"^3.0.0","vfile":"^6.0.0"},"devDependencies":{"@types/node":"^20.0.0","c8":"^10.0.0","prettier":"^3.0.0","remark-api":"^1.0.0","remark-cli":"^12.0.0","remark-preset-wooorm":"^10.0.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^0.58.0"},"scripts":{"prepack":"npm run build && npm run format","build":"tsc --build --clean && tsc --build && 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","remark-api"]},"typeCoverage":{"atLeast":100,"detail":true,"ignoreCatch":true,"strict":true},"xo":{"overrides":[{"files":["**/*.d.ts"],"rules":{"@typescript-eslint/array-type":["error",{"default":"generic"}],"@typescript-eslint/ban-types":["error",{"extendDefaults":true}],"@typescript-eslint/consistent-type-definitions":["error","interface"]}}],"prettier":true,"rules":{"no-constant-condition":"off","unicorn/prefer-at":"off"}},"_id":"vfile-location@5.0.3","gitHead":"8d5d41dca227bc2d6535d3d293b31287d5d7953f","types":"./index.d.ts","homepage":"https://github.com/vfile/vfile-location#readme","_nodeVersion":"22.0.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==","shasum":"cb9eacd20f2b6426d19451e0eafa3d0a846225c3","tarball":"http://registry-npm.ywwl.com/vfile-location/download/vfile-location-5.0.3.tgz","fileCount":8,"unpackedSize":13089,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDNqIVkBNs2hK0+SK9n2UBJDb9aBMPMI22rUQwHaMWRhQIhAJ/Q6aWpjLSxpaHr7/SM+plOKMlE8p/AFwllLUOPvnFa"}],"size":4889,"noattachment":false,"key":"/vfile-location/-/vfile-location-5.0.3.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vfile-location_5.0.3_1721053767423_0.49452087948319257"},"_hasShrinkwrap":false,"readme":"# vfile-location\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[vfile][] utility to convert between positional (line and column-based) and\noffsets (range-based) locations.\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  * [`Location`](#location)\n  * [`location(file)`](#locationfile)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis is a tiny but useful package to convert between arbitrary places in a\nfile.\n\n## When should I use this?\n\nThis utility is useful when ASTs nodes don’t cut it.\nFor example, when you are making a lint rule that looks for dangerous\ncharacters in a file, which you accomplish by searching the raw file value,\nand still want to report it 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 vfile-location\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {location} from 'https://esm.sh/vfile-location@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {location} from 'https://esm.sh/vfile-location@5?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {VFile} from 'vfile'\nimport {location} from 'vfile-location'\n\nconst place = location(new VFile('foo\\nbar\\nbaz'))\n\nconst offset = place.toOffset({line: 3, column: 3}) // => 10\nplace.toPoint(offset) // => {line: 3, column: 3, offset: 10}\n```\n\n## API\n\n### `Location`\n\nAccessors for index.\n\n###### Fields\n\n* `toOffset` (`(point?: PointLike | null | undefined) => number | undefined`)\n  — get the `offset` from a line/column based `Point` in the bound indices;\n  returns `undefined` when given out of bounds input\n* `toPoint` (`(offset?: number | null | undefined) => UnistPoint | undefined`)\n  — get the line/column based `Point` for `offset` in the bound indices;\n  returns `undefined` when given out of bounds input\n\n### `location(file)`\n\nCreate an index of the given document to translate between line/column and\noffset based positional info.\n\nAlso implemented in Rust in [`wooorm/markdown-rs`][markdown-rs].\n\n[markdown-rs]: https://github.com/wooorm/markdown-rs/blob/main/src/util/location.rs\n\n###### Parameters\n\n* `file` (`VFile | Value`)\n  — file to index\n\n###### Returns\n\nAccessors for index (`Location`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Location`][api-location-map].\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, `vfile-location@^5`,\ncompatible with Node.js 16.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`vfile/.github`][health] for ways to\nget 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/vfile/vfile-location/workflows/main/badge.svg\n\n[build]: https://github.com/vfile/vfile-location/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-location.svg\n\n[coverage]: https://codecov.io/github/vfile/vfile-location\n\n[downloads-badge]: https://img.shields.io/npm/dm/vfile-location.svg\n\n[downloads]: https://www.npmjs.com/package/vfile-location\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=vfile-location\n\n[size]: https://bundlejs.com/?q=vfile-location\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/vfile/vfile/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[contributing]: https://github.com/vfile/.github/blob/main/contributing.md\n\n[support]: https://github.com/vfile/.github/blob/main/support.md\n\n[health]: https://github.com/vfile/.github\n\n[coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[vfile]: https://github.com/vfile/vfile\n\n[api-location-map]: #location\n","publish_time":1721053767567,"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_cnpm_publish_time":1721053767567,"dist-tags":{"latest":"5.0.4"}}