{"name":"unist-util-position-from-estree","version":"2.0.0","description":"unist utility to get a position from an estree node","license":"MIT","keywords":["unist","unist-util","util","utility","recma","esast","estree","javascript","ecmascript","node","position"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/unist-util-position-from-estree.git"},"bugs":{"url":"https://github.com/syntax-tree/unist-util-position-from-estree/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/acorn":"^4.0.0","@types/node":"^20.0.0","acorn":"^8.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":"e489a6ea00bbe773296e68c2e0b4ee14eecee7e0","types":"./index.d.ts","homepage":"https://github.com/syntax-tree/unist-util-position-from-estree#readme","_id":"unist-util-position-from-estree@2.0.0","_nodeVersion":"20.0.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-KaFVRjoqLyF6YXCbVLNad/eS4+OfPQQn2yOd7zF/h5T/CSL2v8NpN6a5TPvtbXthAGw5nG+PuTtq+DdIZr+cRQ==","shasum":"d94da4df596529d1faa3de506202f0c9a23f2200","tarball":"http://registry-npm.ywwl.com/unist-util-position-from-estree/download/unist-util-position-from-estree-2.0.0.tgz","fileCount":7,"unpackedSize":11927,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHb/7ZDhZD6swgSkbGon8FW7Vni9BbwXWv/u6LdpnY5DAiEA1BA9QCc1ZNA5xZhN/V7QGvWHxYtft7FrxnLbmFU0w9g="}],"size":4073,"noattachment":false,"key":"/unist-util-position-from-estree/-/unist-util-position-from-estree-2.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-from-estree_2.0.0_1688724121602_0.3696738335107763"},"_hasShrinkwrap":false,"readme":"# unist-util-position-from-estree\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 a position from an [estree][] 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    *   [`positionFromEstree(node)`](#positionfromestreenode)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a tiny utility that can create a proper unist position from\nan estree node\n\n## When should I use this?\n\nYou can use this package when you want to use other unist utilities with estree\nnodes.\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-from-estree\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {positionFromEstree} from 'https://esm.sh/unist-util-position-from-estree@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {positionFromEstree} from 'https://esm.sh/unist-util-position-from-estree@2?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {parse} from 'acorn'\nimport {positionFromEstree} from 'unist-util-position-from-estree'\n\n// Make acorn support line/column.\nconst node = parse('function x() { console.log(1) }', {\n  ecmaVersion: 2020,\n  locations: true\n})\n\nconsole.log(positionFromEstree(node)) // `Program`\nconsole.log(positionFromEstree(node.body[0].id)) // `x`\nconsole.log(positionFromEstree(node.body[0].body.body[0].expression)) // Call\n```\n\nYields:\n\n```js\n{\n  start: {line: 1, column: 1, offset: 0},\n  end: {line: 1, column: 32, offset: 31}\n}\n{\n  start: {line: 1, column: 10, offset: 9},\n  end: {line: 1, column: 11, offset: 10}\n}\n{\n  start: {line: 1, column: 16, offset: 15},\n  end: {line: 1, column: 30, offset: 29}\n}\n```\n\n## API\n\nThis package exports the identifier [`positionFromEstree`][positionfromestree].\nThere is no default export.\n\n### `positionFromEstree(node)`\n\nTurn an estree `node` into a unist `position`.\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — estree node\n\n###### Returns\n\nunist position, if valid ([`Position`][position] 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,\n`unist-util-position-from-estree@^2`, compatible with Node.js 16.\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<!-- Definition -->\n\n[build-badge]: https://github.com/syntax-tree/unist-util-position-from-estree/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/unist-util-position-from-estree/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-position-from-estree.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/unist-util-position-from-estree\n\n[downloads-badge]: https://img.shields.io/npm/dm/unist-util-position-from-estree.svg\n\n[downloads]: https://www.npmjs.com/package/unist-util-position-from-estree\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-from-estree\n\n[size]: https://bundlejs.com/?q=unist-util-position-from-estree\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[estree]: https://github.com/estree/estree\n\n[node]: https://github.com/estree/estree/blob/master/es5.md#node-objects\n\n[unist]: https://github.com/syntax-tree/unist\n\n[position]: https://github.com/syntax-tree/unist#position\n\n[positionfromestree]: #positionfromestreenode\n","publish_time":1688724121794,"_cnpm_publish_time":1688724121794,"dist-tags":{"latest":"2.0.0"}}