{"name":"esast-util-from-estree","version":"2.0.0","description":"esast utility to transform from estree","license":"MIT","keywords":["esast","esast-util","util","utility","recma","esast","estree","javascript","ecmascript","tree","ast","transform"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/esast-util-from-estree.git"},"bugs":{"url":"https://github.com/syntax-tree/esast-util-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/estree-jsx":"^1.0.0","devlop":"^1.0.0","estree-util-visit":"^2.0.0","unist-util-position-from-estree":"^2.0.0"},"devDependencies":{"@types/node":"^20.0.0","acorn":"^8.0.0","acorn-jsx":"^5.0.0","c8":"^8.0.0","prettier":"^3.0.0","remark-cli":"^11.0.0","remark-preset-wooorm":"^9.0.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^0.55.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"]},"typeCoverage":{"atLeast":100,"detail":true,"ignoreCatch":true,"strict":true},"xo":{"prettier":true,"rules":{"unicorn/prefer-at":"off","unicorn/prefer-code-point":"off"}},"gitHead":"c84ab4b1b6c7a601159f70b86f0e4cabd641b065","types":"./index.d.ts","homepage":"https://github.com/syntax-tree/esast-util-from-estree#readme","_id":"esast-util-from-estree@2.0.0","_nodeVersion":"20.0.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-4CyanoAudUSBAn5K13H4JhsMH6L9ZP7XbLVe/dKybkxMO7eDyLsT8UHl9TRNrU2Gr9nz+FovfSIjuXWJ81uVwQ==","shasum":"8d1cfb51ad534d2f159dc250e604f3478a79f1ad","tarball":"http://registry-npm.ywwl.com/esast-util-from-estree/download/esast-util-from-estree-2.0.0.tgz","fileCount":7,"unpackedSize":13418,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBcjYvf2r9XnuCZc5T7KidRkguqfde3PpTSkcau4U3fTAiEA2NViqeJdDZir91Jc/TqwxJfR3gGRpIGmOcP8rxbhZas="}],"size":5100,"noattachment":false,"key":"/esast-util-from-estree/-/esast-util-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/esast-util-from-estree_2.0.0_1690792682106_0.08528613437811661"},"_hasShrinkwrap":false,"readme":"# esast-util-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[esast][] utility to transform from [estree][].\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    *   [`fromEstree(estree[, options])`](#fromestreeestree-options)\n    *   [`Options`](#options)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package applies some transforms to a cloned, given estree to make it\ncompatible with unist.\nIt:\n\n*   makes sure nodes are plain JSON\n*   adds unist positions\n*   normalizes `.bigint`\n*   remove `attributes`, `selfClosing` from `JSXOpeningFragment`\n*   removes certain discouraged fields\n\n## When should I use this?\n\nThe transform applied by this utility is often optional: estrees can be used in\nmost places where esast can be used, and vice versa.\nBut, if you come from a unist background and want to deal with JavaScript,\nor want to use unist utilities with JavaScript, this helps a lot.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install esast-util-from-estree\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {fromEstree} from 'https://esm.sh/esast-util-from-estree@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {fromEstree} from 'https://esm.sh/esast-util-from-estree@2?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {parse} from 'acorn'\nimport {fromEstree} from './index.js'\n\n// Make acorn support comments and positional info.\n/** @type {Array<import('acorn').Comment>} */\nconst comments = []\n/** @type {import('estree').Program} */\n// @ts-expect-error: acorn looks like estree.\nconst estree = parse(\n  'export function x() { /* Something senseless */ console.log(/(?:)/ + 1n) }',\n  {\n    sourceType: 'module',\n    ecmaVersion: 'latest',\n    locations: true,\n    onComment: comments\n  }\n)\nestree.comments = comments\n\nconst esast = fromEstree(estree)\n\nconsole.log(esast)\n```\n\nYields:\n\n```js\n{\n  type: 'Program',\n  body: [\n    {\n      type: 'ExportNamedDeclaration',\n      declaration: [Object],\n      specifiers: [],\n      source: null,\n      position: [Object]\n    }\n  ],\n  sourceType: 'module',\n  comments: [\n    {\n      type: 'Block',\n      value: ' Something senseless ',\n      position: [Object]\n    }\n  ],\n  position: {\n    start: {line: 1, column: 1, offset: 0},\n    end: {line: 1, column: 75, offset: 74}\n  }\n}\n```\n\n## API\n\nThis package exports the identifier [`fromEstree`][api-from-estree].\nThere is no default export.\n\n### `fromEstree(estree[, options])`\n\nTurn an estree into an esast.\n\n###### Parameters\n\n*   `estree` ([`EstreeNode`][estree])\n    — estree\n*   `options` ([`Options`][api-options], optional)\n    — configuration\n\n###### Returns\n\nClean clone of `estree` ([`UnistNode`][esast]).\n\n### `Options`\n\nConfiguration (TypeScript Type).\n\n###### Fields\n\n*   `dirty` (`boolean`, default: `false`)\n    — leave discouraged fields in the tree\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][api-options].\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`esast-util-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/esast-util-from-estree/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/esast-util-from-estree/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/esast-util-from-estree.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/esast-util-from-estree\n\n[downloads-badge]: https://img.shields.io/npm/dm/esast-util-from-estree.svg\n\n[downloads]: https://www.npmjs.com/package/esast-util-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=esast-util-from-estree\n\n[size]: https://bundlejs.com/?q=esast-util-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[esast]: https://github.com/syntax-tree/esast\n\n[estree]: https://github.com/estree/estree\n\n[api-from-estree]: #fromestreeestree-options\n\n[api-options]: #options\n","publish_time":1690792682278,"_cnpm_publish_time":1690792682278,"dist-tags":{"latest":"2.0.0"}}